Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: passing parameters



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



Messages sorted by: Reverse Date, Date, Thread, Author