[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $(<file) requotes the quotes?
From: |
Paul Jarc |
Subject: |
Re: $(<file) requotes the quotes? |
Date: |
Mon, 18 Nov 2002 13:24:13 -0500 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu) |
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.
> 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.
> 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.
> I thought $(<file) was supposed to be the same as $(cat file),
It is.
> and I'm certain that cat(1) doesn't do that.
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.
paul