zsh-workers
 help / color / mirror / code / Atom feed
* Why this doesn't work in zsh?
@ 2003-01-14 16:04 DervishD
  2003-01-14 17:39 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: DervishD @ 2003-01-14 16:04 UTC (permalink / raw)
  To: Zsh

    Hi all :))

    I have part of a script that says something like:

    for parameter
    do
    ...
        option=${parameter%=*}
    ...
    done

    This assign the part before '=' to variable 'option', no more, no
less, and uses parameter expansion.

    It has to work with both bash and zsh, but zsh says, when the
assignment is done, '* not found'.

    The problem is the equalsign on the parameter expansion, now I
know, but, why? How can I fix this without making the script
incompatible with bash? What am I doing wrong?

    Thanks a lot :)
    Raúl


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why this doesn't work in zsh?
  2003-01-14 16:04 Why this doesn't work in zsh? DervishD
@ 2003-01-14 17:39 ` Peter Stephenson
  2003-01-14 17:57   ` DervishD
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2003-01-14 17:39 UTC (permalink / raw)
  To: Zsh

DervishD wrote:
>     for parameter
>     do
>     ...
>         option=${parameter%=*}
>     ...
>     done
> 
>     It has to work with both bash and zsh, but zsh says, when the
> assignment is done, '* not found'.

You can stick a backslash before the =; that works in bash, too, since
you can quote any character, even if it's not special.

The problem is that it's using path expansion `=prog', but I couldn't
tell you why it should at that point; in fact, I suspect it shouldn't.
Hence `setopt noequals' or `setopt nonomatch' would remove the problem,
if you can live with the side effects.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why this doesn't work in zsh?
  2003-01-14 17:39 ` Peter Stephenson
@ 2003-01-14 17:57   ` DervishD
  0 siblings, 0 replies; 3+ messages in thread
From: DervishD @ 2003-01-14 17:57 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh

    Hi Peter :)

> >     It has to work with both bash and zsh, but zsh says, when the
> > assignment is done, '* not found'.
> You can stick a backslash before the =; that works in bash, too, since
> you can quote any character, even if it's not special.

    OK, then, that's the solution :)) Thanks a lot :)

> The problem is that it's using path expansion `=prog', but I couldn't
> tell you why it should at that point; in fact, I suspect it shouldn't.
> Hence `setopt noequals' or `setopt nonomatch' would remove the problem,
> if you can live with the side effects.

    Yes, the problem is noequals, I discovered after sending the
message. I can live with side effects, of course, but the problem is
that I cannot tell the script users to set appropriate options when
running this on their systems. The better solution is to quote the
character. Thanks a lot :)))

    Raúl


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-14 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-14 16:04 Why this doesn't work in zsh? DervishD
2003-01-14 17:39 ` Peter Stephenson
2003-01-14 17:57   ` DervishD

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).