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

Re: help with parameters



>hello,
>i don't understand why the following expression doesn't work
>
>> da="--date '1 September' +'%A'" ; date $da
>
>and this one works
>
>> date --date '1 September' +'%A'

The first one sets da to be a single string, and then passes it, as a
single argument, to date.  The second one passes three separate
strings.  A possible method that would work is

da=(--date '1 September' +'%A') ; date $da

which makes da an array of three strings, and passes it, as three
arguments, to date.  Another possibility is

 
da="--date '1 September' +'%A'" ; eval date $da

which I think is closer to what you were trying to do.  It makes da a
string as you did, then expands it on the eval command line.  eval
reparses its arguments, interpreting the single quotes embedded in da.

-zefram



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