In <[EMAIL PROTECTED]>, Jun Kuriyama wrote: 
> #!/bin/sh
> cat <<EOF
> [8bit text which contains 0x82 character]

I'm very short of time these days, but here are thoughts and a

0x82 == \202 == CTLVAR in the parser.  For real variable expansion,
the parser inserts \202 into the input string.

Furthermore, it is an error that the forking shell doesn't detect that
its forked counterpart dumped core.

I see two solutions:
1) It seems that you can work around the coredump by looking at the
   next char after \202.  For real expansions of variables in
   here-documents that is \201.  Once can probably determine all
   possible legal combinations and ignore others.  However, that
   would just prevent this coredump and would not support processing
   the CTL* chars as literal chars in here-documents, at the very
   least they will be eaten.

2) move the CTL* stuff from expand.h to values outside the char
   domain.  Do do this, all input strings must be converted from char*
   to int* in the first steps of the parser, all buffers must hold
   int*, which means that they cannot be displayed to the terminal or
   presented as input to external programs without converting them

Of course, I will do the latter :-) However, I'm in the middle of
preparation for a job interview, so that is not possible right now.

Anyone trying to fix this, especially going the first path, keep in
mind that you must not break variable expansion in here-documents:

cat <<EOF
echo $foo

(gdb) bt
#0  evalvar (p=0x80b998c "\na;sldk\n", flag=0) at expand.c:783
#1  0x804ce8e in argstr (p=0x80b9980 "jhsdd903kd\n\202\na;sldk\n", flag=0)
    at expand.c:245
#2  0x804cc26 in expandarg (arg=0x80b9998, arglist=0x0, flag=0) at expand.c:169
#3  0x804cbbb in expandhere (arg=0x80b9998, fd=3) at expand.c:144
#4  0x8056d22 in openhere (redir=0x80b994c) at redir.c:269
#5  0x8056bd5 in openredirect (redir=0x80b994c, memory=0xbfbff1f8 "")
    at redir.c:226
#6  0x8056a59 in redirect (redir=0x80b994c, flags=0) at redir.c:157
#7  0x804b9ae in evalcommand (cmd=0x80b9970, flags=1, backcmd=0x0)
    at eval.c:888
#8  0x804a920 in evaltree (n=0x80b9970, flags=0) at eval.c:269
#9  0x8051a47 in cmdloop (top=1) at main.c:253
#10 0x80519b5 in main (argc=2, argv=0xbfbff3f8) at main.c:202
#11 0x8048135 in _start ()

Martin Cracauer <[EMAIL PROTECTED]>
BSD User Group Hamburg, Germany

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to