[plt-scheme] mzscheme/shell script fails when "!" is near end of command-line argument

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Tue Jul 13 04:57:54 EDT 2004

I think you are correct in your suspicion that this is Bash's fault,
nothing to do with MzScheme.

I believe that Bash's csh-like command history is not supposed to be
enabled for batch (non-interactive) shells, but your Bash installation
or init files might be enabling it anyway.

To make your scripts most robust, I suggest putting a "set +H" in your
"/bin/bash" scripts (or perhaps there is some better Bash-ism for that).

Better yet, you could rewrite the entire script in MzScheme, especially
since the way "$1" is expanded in your script has more escaping problems
than just "!".

     claire ~  bash 
    neil at claire:~$ echo "foo!"
    bash: !": event not found
    neil at claire:~$ echo "foo\!"
    foo\!
    neil at claire:~$ echo 'foo!'
    foo!
    neil at claire:~$ set +H
    neil at claire:~$ echo "foo!"
    foo!
    neil at claire:~$ echo `echo "foo!"`
    foo!
    neil at claire:~$ exit
    exit
     claire ~  /bin/bash +H
    neil at claire:~$ echo "foo!"
    foo!
    neil at claire:~$ 


Posted on the users mailing list.