Just a thought on sed

Nicholas Dille darkyeti at gmx.net
Mon May 6 05:47:14 PDT 2002


On Mon, May 06, 2002 at 08:32:03AM -0400, Phil Gendreau wrote:
> * Nicholas Dille <darkyeti at gmx.net> [2002-05-06 10:18]:
> > i said that $(sed 's/foo/bar/' file) might
> > produce a string which contains ` and ' to delimit values or substrings.
> > if that happens you will get a string similar to what you quoted from my
> > previous post
> 
> Hi Nicholas,
> could you provide a concrete example?
> I don't see where it can break, but would like to.
> 
> echo foo\`temp\'bar
> does produce a string which contains ` and ' but
> echo "$(echo foo\`temp\'bar)" just outputs foo`temp'bar.
> (e.g.: it is not executing echo "foo`temp'bar" so 
> echo "$(command)" = command for what I can see)

alright, here you go:

consider piping the output of 'make && make install' of some package
into a file:

	# make && make install > LOG 2>&1

for big projects which use recursive make call or descent into
directories, make prints a nice line when entering and leaving a
directory in the manner of:

	make: Entering directory `foo/bar'
	.
	.
	.
	make: Leaving directory `foo/bar'

now, when using the command which you proposed:

	# echo "$(sed 's/foo/bar/g' LOG)" > LOG

this will produce a pattern similar to "foo`temp'bar" which i was
talking about.
the string between any two backticks ` will be interpreted as
commands and will obviously fail.

that is what i meant.
nic.

-- 
rakshas at quietude / 7793747 / rakshas dot de
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list