Skip to main content
added 138 characters in body; added 19 characters in body
Source Link
Stéphane Gimenez
  • 29.1k
  • 3
  • 76
  • 87

Talking about differences between zsh and bash:

With quotes around $@ and $*, zsh and bash behave the same, and I guess the result is quite standard among all shells:

 $ f () { for i in "$@"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a+
 +b+
 ++
 $ f () { for i in "$*"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a b +

Without quotes, results are the same for $* and $@, but different in bash and in zsh. In this case zsh shows some odd behaviour:

bash$ f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''
+a+
+a+
+b+
zsh% f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''  
+a a+
+b+

(Zsh usually don't split textual data using IFS, unless explicitly requested, but notice that here the empty argument is unexpectedly missing in the list.)

Talking about differences between zsh and bash:

With quotes around $@ and $*, zsh and bash behave the same, and I guess the result is quite standard among all shells:

 $ f () { for i in "$@"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a+
 +b+
 ++
 $ f () { for i in "$*"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a b +

Without quotes, results are the same for $* and $@, but different in bash and in zsh. In this case zsh shows some odd behaviour:

bash$ f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''
+a+
+a+
+b+
zsh% f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''  
+a a+
+b+

Talking about differences between zsh and bash:

With quotes around $@ and $*, zsh and bash behave the same, and I guess the result is quite standard among all shells:

 $ f () { for i in "$@"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a+
 +b+
 ++
 $ f () { for i in "$*"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a b +

Without quotes, results are the same for $* and $@, but different in bash and in zsh. In this case zsh shows some odd behaviour:

bash$ f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''
+a+
+a+
+b+
zsh% f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''  
+a a+
+b+

(Zsh usually don't split textual data using IFS, unless explicitly requested, but notice that here the empty argument is unexpectedly missing in the list.)

Source Link
Stéphane Gimenez
  • 29.1k
  • 3
  • 76
  • 87

Talking about differences between zsh and bash:

With quotes around $@ and $*, zsh and bash behave the same, and I guess the result is quite standard among all shells:

 $ f () { for i in "$@"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a+
 +b+
 ++
 $ f () { for i in "$*"; do echo +"$i"+; done; }; f 'a a' 'b' ''
 +a a b +

Without quotes, results are the same for $* and $@, but different in bash and in zsh. In this case zsh shows some odd behaviour:

bash$ f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''
+a+
+a+
+b+
zsh% f () { for i in $*; do echo +"$i"+; done; }; f 'a a' 'b' ''  
+a a+
+b+