delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/01/15/22:36:51

X-Spam-Check-By: sourceware.org
Message-ID: <45AC4851.3090508@byu.net>
Date: Mon, 15 Jan 2007 20:36:49 -0700
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com, luke DOT kendall AT cisra DOT canon DOT com DOT au
Subject: Re: Changed handling of "!" in /bin/sh?
References: <20070116031524 DOT 167A083D05 AT pessard DOT research DOT canon DOT com DOT au>
In-Reply-To: <20070116031524.167A083D05@pessard.research.canon.com.au>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

-----BEGIN PGP SIGNED MESSAGE-----
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             ebb9 AT byu DOT net
-----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

iD8DBQFFrEhQ84KuGfSFAYARAjETAJ9u/299Pot4ugAvPVh+Z/vVTiovIwCgmsWw
IdFw+6CYppgCfJojwFAjF4M=
=lbyV
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019