bug-bash
[Top][All Lists]
Advanced

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

Re: [50 character or so descriptive subject here (for reference)]


From: Chet Ramey
Subject: Re: [50 character or so descriptive subject here (for reference)]
Date: Mon, 13 May 2002 12:54:57 -0400

> Machine Type: sparc-sun-solaris2.5.1
> 
> Bash Version: 2.02
> Patch Level: 1
> Release Status: release
> 
>     Description:
>           IFS in-line interpretation on command line inconsistant with
>           other semi-POSIX shells

OK.  The relevant information is found in two places in the bash reference
manual (the texinfo/info file).

First, look at the description of simple command expansion.  Variable
assignments preceding a simple command do not affect expansion for
that command.  They are saved until after the rest of the words have
been expanded, and then passed to the executed command in its
`environment'.  For commands executed from the file system,  this is
straightforward:  the variable gets passed in the environment.  For builtins,
it means that variable lookups performed while the builtin is executing will
see the new values.  This is how you can change how words are split by `read',
for instance.

This is why the first assignment

>       bash-2.02$ IFS=":${IFS}" echo $FOO
>       a:b:c

doesn't affect how $FOO is split.

This means that for other shells to behave as you observed, the assignment
to IFS must persist somehow, and affect subsequent expansions.  This is
the part that is affected by posix mode.  In the posix mode description, we
find

@item
Assignment statements preceding @sc{posix} 1003.2 special builtins
persist in the shell environment after the builtin completes.

By default, bash treats all builtins uniformly, regardless of whether or not
posix has identified them as `special' (each bash builtin is special in its
own way :-).  The consequence in this case is that IFS won't change:
variable assignments preceding a command remain in effect only for the
duration of that command, regardless of whether or not they're builtins or
external commands.

>       bash-2.02$ IFS=":${IFS}" set $FOO
>       bash-2.02$ echo $*
>       a:b:c


>     When run with --posix, bash-2.02 performs as do the other shells,
>     ie, the third echo command produces 'a b c'.  However, I can find
>     no documentation anywhere decribing standard bash behavior as
>     varying from POSIX on this issue, and the bash documentation on
>     the effect of changing IFS so similar to the documentation on other
>     shells that it leads me to think this is unexpected.

It's in the info file, as quoted above.  Bash distributions (at least as
far back as bash-2.01 -- I didn't check further) have the posix-mode stuff
in a separate file, CWRU/POSIX.NOTES.  I'll probably move that into the
top-level directory in a future distribution, since it's not in the manual
page.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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