help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Is there a particular reason that $@ is expanded to a st


From: Stephane Chazelas
Subject: Re: [Help-bash] Is there a particular reason that $@ is expanded to a string *using a space as separator instead of $IFS* in contexts where word splitting is not performed?
Date: Sun, 6 Sep 2015 21:00:11 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-09-06 12:11:08 +0800, ziyunfei:
> $ set -- 1 2 3
> $ IFS=:
> $
> $ # in a [[...]] command
> $ [[ $@ == "1 2 3" ]]; echo $? 
> 0 # print 1 in zsh
> $ [[ $@ == "1:2:3" ]]; echo $?
> 1 # print 0 in zsh
> $
> $  # in the rhs of an assignment statement
> $ foo=$@
> $ IFS=
> $ echo $foo
> 1 2 3 # print 1:2:3 in zsh
> 
> $* use the first character of $IFS as separator in these cases
> but $@ doesn’t. Does POSIX standard mention this, or this is
> just a historical behavior of Bourne shell? And I found a
> possibily relevant comment in the Bash source code
> http://code.metager.de/source/xref/gnu/bash/subst.c#8858, it
> says “it's what other shells seem to do”.

You may want to read this thread at the Austing group mailing
list:

http://thread.gmane.org/gmane.comp.standards.posix.austin.general/9972/focus=10005

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]