This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Changed handling of "!" in /bin/sh?

Hash: SHA1

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":
> #!/bin/sh
> echo "Hello world!"
> SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:igncr:interactive-comments:monitor

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   
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Mozilla -


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]