bug-bash
[Top][All Lists]
Advanced

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

Re: IFS valid characters


From: Stephane CHAZELAS
Subject: Re: IFS valid characters
Date: Tue, 17 Mar 2009 19:15:52 +0000 (UTC)
User-agent: slrn/pre1.0.0-2 (Linux)

2009-03-16, 09:53(+01), Dave B:
> Stephane CHAZELAS wrote:
>
>> 2009-03-10, 15:43(-04), Chet Ramey:
>>>> What are the valid charactes for the IFS variable? In particular, is '\0' 
>>>> a 
>>>> valid one? 
>>> Technically, yes, but in practice it's not useful.  There are too many 
>>> things
>>> represented as C strings to make NUL work right.
>> [...]
>> 
>> And to answer the rest of the question. In bash, any character
>> except NUL is allowed in $IFS.
>> 
>> Some points that should be noted:
>>   - the SPC, TAB and NL characters are treated specially.
>>   - contrary to in the Bourne shell, pdksh or zsh, IFS is an
>>     internal field terminator, not separator ("a:b:" is split
>>     into "a" and "b", not "a" and "b" and "" which makes it
>>     inappropriate to split $PATH for instance) (in the Bourne
>>     shell, it splits into "a" and "b" as well but that's because
>>     empty elements are removed there)
>
> It looks like an empty word is created when the separator is at the
> beginning, but not when it's at the end (bash 3.2 and 4):
[...]

Yes, hence "internal field terminator" and not "internal field
introducer".

-- 
Stéphane


reply via email to

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