From: zzapper <david@tvis.co.uk>
To: zsh-users@sunsite.dk
Subject: Re: passing parameters
Date: Fri, 06 May 2005 13:54:38 +0100 [thread overview]
Message-ID: <h8pm71l1hhufkpk2s2kkl4apejpmph0mr3@4ax.com> (raw)
In-Reply-To: <1050506035734.ZM31409@candle.brasslantern.com>
On Fri, 06 May 2005 03:57:34 +0000, wrote:
>
>Er, "not treated the same" how? There's nowhere near enough context
>here for anything useful to be said.
Sorry Bart
Turns out it's nowt to do with passing parameters (I give two versions of the same script)
So if I want to edit a tex file somewhere in a file tree which has got say "family" as part of it's
file name I type
> ftx family
maybe however there's more than one file so I type a "regexp" such
> ftx "family.*tree"
That works fine, so then I think lets pass the "regexp" as two parameters to save a bit of typing
> ftx family tree
However that's where I run into trouble
with
param="$1.*$2"
but use of $param breaks the following script
ftx () {
if [ $# -gt 0 ]
then
cd /c/intranet/latex/
cnt=$(ls **/*.tex |egrep -ic "$1[^/]*.tex" )
texfile=$(ls **/*.tex |egrep -i "$1[^/]*.tex" )
if [ $cnt -eq 1 ]
then
gvim.exe $texfile
else
echo $texfile
fi
else
echo please enter a keyword to search for tex file
fi
}
SO I HAVE TO WRITE $param AS ${param} IN FOLLOWING WORKING SCRIPT
function ftx()
{
if [ $# -gt 0 ]
then
if [ $# -gt 1 ]
then
param="$1.*$2"
else
param=$1
fi
cd /c/intranet/latex/
cnt=$(ls **/*.tex |egrep -ic "${param}[^/]*.tex" )
texfile=$(ls **/*.tex |egrep -i "${param}[^/]*.tex" )
if [ $cnt -eq 1 ]
then
gvim.exe $texfile
else
echo $texfile
fi
else
echo please enter a keyword to search for tex file
fi
}
But why is it necessary to write ${param} ? and it wasn't necessary to write ${1}
--
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips
next prev parent reply other threads:[~2005-05-06 12:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-05 21:42 zzapper
2005-05-06 3:57 ` Bart Schaefer
2005-05-06 12:54 ` zzapper [this message]
2005-05-06 16:03 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=h8pm71l1hhufkpk2s2kkl4apejpmph0mr3@4ax.com \
--to=david@tvis.co.uk \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).