Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: EXEC peculiarities
- X-seq: zsh-users 7851
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Jay Guerette <JayGuerette@xxxxxxxxx>
- Subject: Re: EXEC peculiarities
- Date: Sun, 15 Aug 2004 11:02:15 -0700
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <48120.217.160.254.91.1092590696.squirrel@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <46981.217.160.254.91.1092582879.squirrel@xxxxxxxxxxxxxx> <912.411f8c59.a67bb@xxxxxxxxxxxxxxxxxxx> <48120.217.160.254.91.1092590696.squirrel@xxxxxxxxxxxxxx>
On Sun, Aug 15, 2004 at 01:24:56PM -0400, Jay Guerette wrote:
> Ok. So in the following examples, would the 1st form; ${(s: :)EXEC}; be
> preferred, since the documentation says using the 2nd form; ${=EXEC};
> forces SH_WORD_SPLIT on; potentially leading to unexpected behavior later?
${=VAR} only forces SH_WORD_SPLIT on for the duration of the variable's
expansion, so it's a good way to go when you need to use it.
However, I'd recommend just starting with an array in the first place,
when possible:
#!/bin/zsh
EXEC=(/sbin/ifconfig eth0)
exec $EXEC
The nice thing about this idiom is that it preserves args that have
spaces in them:
#!/bin/zsh
file1='this one.txt'
EXEC=(/bin/ls $file1 'that one.txt')
exec $EXEC
If you put that in a string and split it, it would not preserve the
multi-word args:
#!/bin/zsh
file1='this one.txt'
EXEC="/bin/ls $file1 that\\ one.txt"
exec ${=EXEC}
That would try to list "this", "one.txt", "that\", and "one.txt" (just
like bash would handle the string).
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author