bug-bash
[Top][All Lists]
Advanced

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

Re: $(<file) requotes the quotes?


From: Phil Edwards
Subject: Re: $(<file) requotes the quotes?
Date: Mon, 18 Nov 2002 19:16:49 -0500
User-agent: Mutt/1.2.5i

On Mon, Nov 18, 2002 at 01:24:13PM -0500, Paul Jarc wrote:
> For help with writing scripts, go to news:comp.unix.shell.
> 
> Phil Edwards <phil@jaj.com> wrote:
> > Since I can't use 'read' in a loop,
> 
> I bet you can, if you do it right.

The bash FAQ specifically points out that the construct I want to use does
not work by design.  I did my homework.


> > I am instead accumulating strings in a temporary file.  The strings
> > are "-e" commands that will eventually be fed to sed(1).
> 
> Maybe you'd like sed -f.

Nope, for reasons I don't want to go into here.  But it's otherwise a
good suggestion.


> >     sed -e 'required stuff'                                     \
> >         -e 'more required stuff'                                \
> >         ...
> >         -e 'more required stuff'                                \
> >         $(</temporary/file/with/accumulated/optional/stuff)     \
> >         input_file > output_file
> >
> > But sed chokes, because the single-quote characters in the file are being
> > quoted and backslash-escaped all over the place.
> 
> More precisely, quoting and quote removal are not applied to the
> result of the $() expansion; only word splitting is.  This is correct,
> documented behavior.

Where?  "Command Substitution" doesn't mention anything about quoting or
quote removal.  The section on "Quote Removal" talks about "the preceeding
expansions," and makes no exception for command substitution.


> Nor does $(<file).  It's a matter of what *isn't* being done, which
> normally is done (by bash) for text that is part of the script itself.
> You would see the same behavior with cat.

Ah.  Bummer.


Thanks for the answer!

Phil

-- 
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
                                                 - Edsger Dijkstra, 1930-2002




reply via email to

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