Re: sed? insanity
>>>>> "Clint" == Clint Adams <schizo@debian.org> writes:
A better title would be "make makes sed insane".
I don't know exactly what is wrong, but can tell you how to
fix it ;-)
I will leave it up to you if you want to trust my solution or not...
Clint> This is driving me batty. Can anyone tell me what's broken here?
Clint> % ./shtest weird
Clint> t: s,$,weird,
Clint> s: TESTweird
Clint> % make -f maketest test
Clint> t: make[1]: Entering directory `/tmp'
Clint> s,$,weird,
Clint> make[1]: Leaving directory `/tmp'
Clint> sed: -e expression #1, char 1: Unknown command: ``m''
Clint> s:
Clint> -----8<-----
Clint> #!/bin/sh
Clint> # shtest
Clint> weird="s,\$\$,$1,"
Clint> t=`make -f - <<EOF
Clint> all:
Clint> @echo $weird
Clint> EOF`
Clint> echo "t: $t"
To fix the problem:
1. put t="" before sed command. This fixes the problem, even with
3.
or
2. Put "unset MAKELEVEL" before the sed command - at least this fixes
the problem for me.
or
3. Put "export MAKELEVEL=1" before the sed command - now
it crashes every time!!! (See below)
Clint> s=`echo TEST | sed -e "$t"`
Clint> echo "s: $s"
Clint> -----8<-----
Clint> #!/usr/bin/make
Clint> # maketest
Clint> test:
Clint> @./shtest 'weird'
Clint> -----8<-----
[720] [snoopy:bam] ~ >./shtest
t: make[1]: Entering directory `/homes/bam'
s,$,,
make[1]: Leaving directory `/homes/bam'
sed: -e expression #1, char 1: Unknown command: ``m''
s:
Running
sh -x shtest,
it would appear that sed is running a copy of make,
but I don't know why.
Arrghh... I see your problem. I think it is related to the
following prompts from Make:
make[1]: Leaving directory ...
and
make[1]: Entering directory ...
which somehow confuse sed. Or perhaps the shell is getting
confused, and mangles the result before sed sees it.
--
Brian May <bam@debian.org>
Reply to: