zsh-users
 help / color / mirror / code / Atom feed
* Re: please advice
@ 2000-06-30 11:39 Sven Wischnowsky
  2000-06-30 12:03 ` Mircea Damian
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 2000-06-30 11:39 UTC (permalink / raw)
  To: zsh-users


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@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: please advice
@ 2000-06-30 12:14 Sven Wischnowsky
  2000-06-30 12:17 ` Mircea Damian
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 2000-06-30 12:14 UTC (permalink / raw)
  To: zsh-users


Mircea Damian wrote:

> ...
> 
> I don't see what can be wrong if I use word splitting on that variable(btw,
> word splitting is done by using WORDCHARS or just white spaces?).. is there
> somewhere an impediment for that?

It uses the characters from $IFS for word splitting.

The advantage of using arrays is the easier handling if the words
contain spaces, which, of course, isn't important in your example (but 
it may be a good idea to get used to it anyway).

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 7+ messages in thread
* please advice
@ 2000-06-30 11:27 Mircea Damian
  0 siblings, 0 replies; 7+ messages in thread
From: Mircea Damian @ 2000-06-30 11:27 UTC (permalink / raw)
  To: zsh-users


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?



-- 
Mircea Damian
E-mails: dmircea@kappa.ro, dmircea@roedu.net
WebPage: http://taz.mania.k.ro/~dmircea/


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

end of thread, other threads:[~2000-06-30 12:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-30 11:39 please advice Sven Wischnowsky
2000-06-30 12:03 ` Mircea Damian
2000-06-30 12:16   ` Andrej Borsenkow
2000-06-30 12:21     ` Mircea Damian
  -- strict thread matches above, loose matches on Subject: below --
2000-06-30 12:14 Sven Wischnowsky
2000-06-30 12:17 ` Mircea Damian
2000-06-30 11:27 Mircea Damian

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).