bug-bash
[Top][All Lists]
Advanced

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

$(<file) requotes the quotes?


From: Phil Edwards
Subject: $(<file) requotes the quotes?
Date: Fri, 15 Nov 2002 21:56:24 -0500
User-agent: Mutt/1.2.5i

I am using 2.05b.0(1)-release, as installed on Debian.

Since I can't use 'read' in a loop, I am instead accumulating strings in
a temporary file.  The strings are "-e" commands that will eventually be
fed to sed(1).  So the temporary file contains

    -e 's,foo1,bar1 with spaces,'
    -e 's,foo2,bar2 with spaces,'
    -e 's,foo3,bar3 with spaces,'
    ...

And then finally this happens:

    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.  Running the script with
-x, I see that this is the command being exceuted (linewrapped for posting):

    sed [...the required stuff, all good...]
        -e ''\''s,foo1,bar1' with 'spaces,'\'''
        -e ''\''s,foo2,bar2' with 'spaces,'\'''

and sed naturally complains:

    sed: -e expression #5, char 1: Unknown command: ``'''


I am confused.  Why is bash sticking all those extra quotes in there?
I thought $(<file) was supposed to be the same as $(cat file), and I'm
certain that cat(1) doesn't do that.


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]