[gnu.bash.bug] A bug... I think.

root@devon.lns.pa.us (Mark Buda) (07/25/89)

Hello again. I'm running bash 1.02 under Genix 4.1 on a box with lots of cables
hanging out of it. I think I've found a bug, but I'm not absolutely sure. It's
certainly an incompatibility with my /bin/sh.

The symptom: after executing a "." command, bash forgets the value of $2 (for
instance).

The following script should print its first argument, but instead it prints
a blank line.

-- cut here --
#! /usr/local/bin/bash
. /dev/null
echo $1
-- cut here --

After thinking a bit, I discovered that if I replace the second line with
. /tmp/moo foobie
where /tmp/moo is a file containing the line
echo $1
bash will print foobie twice. Apparently bash is sticking the parameters from
the "." line into dollar_vars instead of saving the old values and restoring
them.

Is the fix anything more complicated than replacing
      remember_args (list->next, 1);
      string[finfo.st_size] = '\0';
      return (parse_and_execute (string));
with
      push_dollar_vars();
      remember_args (list->next, 1);
      string[finfo.st_size] = '\0';
      temp = parse_and_execute (string);
      pop_dollar_vars();
      return temp;
or should I use p{ush,op}_context, or what?

Mark Buda
hermit@chessene.uucp
hermit%chessene.uucp@rutgers.edu
devon.lns.pa.us!chessene!hermit
...!rutgers!devon!chessene!hermit