bug-bash
[Top][All Lists]
Advanced

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

Re: Short list of issues with various expansions and IFS


From: Dan Douglas
Subject: Re: Short list of issues with various expansions and IFS
Date: Tue, 29 Jan 2013 23:16:08 -0600
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

Hey thanks for all the nice explanations. I'm sure I'll reference this in the 
future.

> >  3. Another IFS oddity via "command"
> > 
> > IFS can be given "two values at once" through the environment of a 
> > redirection.
> 
> I have to look at this one.  It's clear that the temporary environment
> given to `command' is like the temp environment supplied to `eval', and
> needs to persist through all of the commands executed by `command'.  I
> have to figure out whether that temporary environment counts as the temp
> environment to `cat' (I don't think so) and how to reconcile the variable
> lookups during redirection expansion.

I think at least the variable should be accessible to builtins or functions 
run by `command' (if not cat). Maybe you meant it doesn't actually get 
exported to non-builtins? In this case, the redirect should be applying to the 
`command' command, so the outer environment is what applies to the redirect 
just like any other normal command (I think).

I forgot to mention also that related to this issue, Bash is the only shell 
that does word-splitting on here-strings in the first place. The others treat 
the words expanded after the redirect as in an unquoted here-document, except 
with quote-removal despite having no wordsplitting or globbing (while in a 
heredoc, there's no quote removal either). So Bash for instance will trim 
whitespace down to 1 space if you don't quote herestring contents, while 
others don't, and treat the herestring almost exactly like the word following 
`in' in a case..esac.

There's also a documentation bug related to this:

"The word following the redirection operator in the following descriptions, 
unless otherwise noted, is subjected to brace expansion, tilde expansion, 
parameter expansion, command substitution, arithmetic expansion, quote  
removal,  pathname expansion, and word splitting. If it expands to more than 
one word, bash reports an error."

Here-strings are of course an exception to the last sentence, and possibly an 
exception to parts of the previous sentence (here-strings are defined in terms 
of the here-document, which might make the issue not so straightforward).

-- 
Dan Douglas



reply via email to

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