Re: why tcl/tk doesn`t incorporate tclx, tile, etc.



On Mar 10, 5:22 pm, heiner.mar...@xxxxxxxx (Heiner Marxen) wrote:
In article <f9e3cb96-f42c-43a1-8b8e-27debbec6...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx> writes:> On Mar 8, 11:58 pm, Witek Mozga <mo...@xxxxxxxxxxxxxxxxx> wrote:
Can you post a few lines around line 17042 ?

cat >confdef2opt.sed <<\_ACEOF

note this quoting---------^



t clear
: clear
s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g
t quote
s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g
t quote
d
: quote
# Below is 17042nd line
s,[ `~#$^&*(){}\\|;'"<>?],\\&,g
s,\[,\\&,g
s,\],\\&,g
s,\$,$$,g
p
_ACEOF
Strangely I cannot reproduce the problem, though I tried the bash/ksh
pair on several Linuxes and a Solaris...
I'm not sure, but in the above several things seem to be wrong:
Shouldn't the block given to "<<" be dollar- and backquote-substituted
by the shell ?

Since (part of) the delimiter word (_ACEOF) is quoted, all expansion
inside the here document should be suppressed.

But the error message looks like the backtick is interpreted as
the start of an embedded command :

syntax error near unexpected token `{}\\'
./configure: line 17042: `s,[ `~#$^&*(){}\\|;'"<>?],\\&,g'

The unexpected token end before a pipe character, supporting this view.
Why bash tries to expand backticks at this place, although is shouldn't
(and ksh doesn't), I have no idea, short of suspecting a bash bug.

What exact version of bash do you use? (bash --version)

I'm using 3.00.0(1) without your problem (backtick is taken literally).

I continued to experiment a bit with my bash 3.00.0(1)...

When I delete the backslash before _ACEOF I get this error:
yy1: command substitution: line 1: syntax error near unexpected token `{}\|'
yy1: command substitution: line 1: `~#$^&*(){}\|;'"<>?],\&,g'

which looks different from your error message.
BUT... when I prepend a command and open a backtick like this
: `
before all your code, I get:
yy1: line 11: syntax error near unexpected token `{}\\'
yy1: line 11: `s,[ `~#$^&*(){}\\|;'"<>?],\\&,g'

which matches your error text much better.

Hence I suspect, that bash parses the above code as part of an already
opened backtick enclosed token... for reasons unknown to me.
The cause has to be before the code we saw so far.

Hope this helps somewhat.
--
Heiner Marxen http://www.drb.insel.de/~heiner/

Thanks a huge lot Heiner ! The backslash after << did hit my
peripheral nervous system, but I dismissed it under the load of other
metacharacters ;-)

To the OP: a possible fix (among others) is to program defensively
against bash bugs, by avoiding to use the backslash after <<.
Doing this, of course, implies to escape all backquotes, dollars,
*and* backslashes in the << bodies. No free lunch :-)

Personally, to do the same (build temporary sed scripts with highly
active chemicals inside *and* things to be substituted), I prefer to
use the shell's virtuosity with alternating single quotes and naked or
double-quoted variables:

sedscript='s/CHEMICALS/'"$var"'/g'

this gives better control over the substituted vs. protected parts
than the << operator. The cost being the '\'' everywhere you need a
literal single quote between single quotes. Who talked about free
lunches ?

-Alex



.



Relevant Pages

  • Re: Spaces in UNIX Filenames Bad
    ... >> because of the way bash treats space characters the solution wasn't ... > What if there are filenames which contain quotes? ... >> # get position of trailing double quote ... Enrique, Chris, thank you both for your thoughtful comments. ...
    (comp.os.linux.misc)
  • Re: (NDC) You Cant Make Up Stuff This Funny
    ... other person who read the quote had concurred with you, ... it fun to bash you when you deserve it. ... no evocation of the people who were buried in cement in 9/11 is ... evocation is therefore not resonant regardless? ...
    (rec.music.gdead)
  • Re: why tcl/tk doesn`t incorporate tclx, tile, etc.
    ... the start of an embedded command: ... Why bash tries to expand backticks at this place, ... I'm using 3.00.0without your problem (backtick is taken literally). ...
    (comp.lang.tcl)
  • Re: Spaces in UNIX Filenames Bad
    ... In perl the solution was fairly easy but because of the way bash treats space characters the solution wasn't quite as obvious. ... expansion Bash performs on the text of a command, ...
    (comp.os.linux.misc)
  • Re: handling apostrophe
    ... Try changing ur routine such that single quotes are replaced with double ... > will determine tha filter. ... >> quote is the defined and documented way to get a single quote into the ...
    (microsoft.public.sqlserver.programming)