Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Script interpreting a command strangely
- X-seq: zsh-users 13704
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Webb Sprague <webb.sprague@xxxxxxxxx>
- Subject: Re: Script interpreting a command strangely
- Date: Sun, 11 Jan 2009 20:36:34 -0800
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=d200807; d=spodhuis.org; h=Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=x6fRCq+XTOOw2XcZuwauw83Nfp3ModYo9DfVcz/rWQ5rWDJfG7nmraTfwE7zh+odpu3X0asimjFwmc3ZT6UIiQrF4F7A9ku1qDpwPNKnshy5SNM1DKI5+DWq/sVaYhl9YO+28Q6U3z+yal9LqqMlJoDvzXeRw1j0FQ5NILCQd6s=;
- In-reply-to: <b11ea23c0901112009pa2c5336wf6ed080eafd8611a@xxxxxxxxxxxxxx>
- Mail-followup-to: Webb Sprague <webb.sprague@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b11ea23c0901112009pa2c5336wf6ed080eafd8611a@xxxxxxxxxxxxxx>
On 2009-01-11 at 20:09 -0800, Webb Sprague wrote:
> #!/usr/bin/env zsh
> PGOPT=' -q -A -t -U mkn_f -h xxx.yyy.pdx.edu zzz' # command for DB
> PG="psql $PGOPT "
> psql $PGOPT
> $PG
> echo psql $PGOPT
zsh is not sh (by default) and does not split scalar variables on
whitespace, as POSIX sh does.
You can use arrays, or use "emulate sh", or "setopt SH_WORD_SPLIT".
Or you can word-split on a given variable expansion by prefixing the
name with '=' which is equivalent to SH_WORD_SPLIT being on for just
that one expansion.
...% zsh -f
redoubt% foo='echo bar'
redoubt% $foo
zsh: command not found: echo bar
redoubt% $=foo
bar
redoubt%
See zshoptions and zshexpn man-pages.
Regards,
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author