Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: aliases not getting expanded inside functions?
- X-seq: zsh-users 5688
- From: Carlos Carvalho <carlos@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: aliases not getting expanded inside functions?
- Date: Mon, 13 Jan 2003 15:59:25 -0200
- In-reply-to: <1030111184020.ZM11764@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <15893.44217.393956.262362@xxxxxxxxxxxxxx> <20030103164552.A28966@xxxxxxxxxxx> <15893.50996.646711.184945@xxxxxxxxxxxxxx> <20030103184455.A5692@xxxxxxxxxxx> <15893.53780.524763.695176@xxxxxxxxxxxxxx> <20030103185407.GA11836@xxxxxxxx> <15897.15986.562636.628562@xxxxxxxxxxxxxx> <1030106125404.ZM4660@xxxxxxxxxxxxxxxxxxxxxxx> <15903.36155.716460.639226@xxxxxxxxxxxxxx> <1030111184020.ZM11764@xxxxxxxxxxxxxxxxxxxxxxx>
Bart Schaefer (schaefer@xxxxxxxxxxxxxxxx) wrote on 11 January 2003 18:40:
> : ${(P)1::=$2}
> eval $1='$2'
> typeset -g $1=$2
Nice!
>Rather than:
>
> while read dataline
> do
> fields=( "${(@s:;:)dataline}" ) # Answers your other question
Doesn't work for me:
fields=( "${(@s:;:)dataline}" )
print LINE=$dataline
for ((i=1; i <= 16; i++)) { print "fields[$i]=\"$fields[i]\"" }
gives
LINHA="BD CCE";"CCE";"210";"0";"1-254";33;7;1;;;;;;;"permit";
fields[1]=""BD CCE""
fields[2]=""CCE""
fields[3]=""210""
fields[4]=""0""
fields[5]=""1-254""
fields[6]="33"
fields[7]="7"
fields[8]="1"
fields[9]=""permit"" <--- wrong
fields[10]=""
fields[11]=""
fields[12]=""
fields[13]=""
fields[14]=""
fields[15]="" <--- permit should be here
fields[16]=""
> rate=$fields[1] capital=$fields[2] etc.
> # manipulate $rate $capital and so on ...
> done
>
>You can simply do:
>
> while IFS=';' read rate capital etc.
> do
> # manipulate $rate $capital and so on ...
> done
Yes, I didn't do it because I had hope to one day do a block move
via arrays. Also, reading to a parameter first makes it easier to do
some pre-processing like quote removal, otherwise I have to do it
field by field after reading.
>If you're unwilling to use $fields[capital] everywhere -- that is, if
>you insist on being able to write $capital in some cases -- then there
>is no solution I can suggest. However, if it's OK to write e.g.
>
> fields[capital]=$((fields[capital]+fields[interest]))
This makes the program more cumbersome to write and read because all
variables become quite long-named...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author