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

Re: please advice



Mircea Damian wrote:

> Hello,
> 
> I'm trying to use and old bash script and port it to zsh.
> It now basically does:
> 
> #!/bin/zsh
> 
> 
> if [ $# -gt 0 ]; then
>   echo "Number of arguments: $#"
>   exit
> fi
> 
> PRGARG="-bla1 -bla2 -bla3"
> 
> $0 $PRGARG
> 
> 
> In zsh the number of arguments will be 1. How can I expand(?) it to three
> as bash does?

One of the places where zsh differs from other shells, doing the right 
thing.

One possibility is to set the shwordsplit option, if you really want
it everywhere. Our you can force word splitting for that one parameter 
expansion by using: `$=PRGARG'.

The best way would be to use an array, though.

  PRGARG=(-bla1 -bla2 -bla3)
  $0 $PRGARG

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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