This is the mail archive of the
mailing list for the Cygwin project.
Re: Changed handling of "!" in /bin/sh?
- From: Eric Blake <ebb9 at byu dot net>
- To: cygwin at cygwin dot com, luke dot kendall at cisra dot canon dot com dot au
- Date: Mon, 15 Jan 2007 20:36:49 -0700
- Subject: Re: Changed handling of "!" in /bin/sh?
- References: <20070116031524.167A083D05@pessard.research.canon.com.au>
-----BEGIN PGP SIGNED MESSAGE-----
According to Luke Kendall on 1/15/2007 8:15 PM:
> I also just wrote this which fails with a "line 2: !": event not found":
> echo "Hello world!"
There you go. You have "history" enabled in SHELLOPTS, which is a
non-POSIX extension, and explains why /bin/sh is not doing what you
expected. Your shell scripts are inheriting interactive behavior, and
trying to do history expansion when they encounter !. I still hope to
find time to getting around and trying to teach bash which options in
SHELLOPTS should be ignored when starting a non-interactive session. In
the meantime, I would recommend turning history off, or at least changing
the history expansion character, if you absolutely must set SHELLOPTS.
And if all else fails, and you are still running scripts with history
enabled, then according to bash documentation, the only way to bypass the
history character is to quote it, but that in double quotes, "\!"
preserves the \, so you have to write something like:
echo "Hello world"\!
Don't work too hard, make some time for fun as well!
Eric Blake email@example.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html