Mail Archives: cygwin/2012/04/26/10:41:26
X-Recipient: | archive-cygwin AT delorie DOT com
|
X-SWARE-Spam-Status: | No, hits=-10.2 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD
|
X-Spam-Check-By: | sourceware.org
|
Message-ID: | <4F995E78.7020607@redhat.com>
|
Date: | Thu, 26 Apr 2012 08:40:56 -0600
|
From: | Eric Blake <eblake AT redhat DOT com>
|
User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1
|
MIME-Version: | 1.0
|
To: | cygwin AT cygwin DOT com
|
Subject: | Re: Odd behavior of scripts in dos mode
|
References: | <jnbl6p$qav$1 AT dough DOT gmane DOT org>
|
In-Reply-To: | <jnbl6p$qav$1@dough.gmane.org>
|
OpenPGP: | url=http://people.redhat.com/eblake/eblake.gpg
|
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
|
--------------enig117476E124367C5E236978DD
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On 04/26/2012 08:13 AM, Andrew DeFaria wrote:
> I remember that Cygwin used to not be able to run scripts that were
> converted or were in "DOS" mode - had trailing carriage returns in the
> file. It would fail because the #! line might have /bin/bash\r which was
> not a file (bash with a carriage return that is). But the behavior has
> changed. Now it seems to ignore the trailing carriage return and it
> execs bash itself. But it fails later on with other carriage returns.
If you want bash to ignore carriage returns, then ask it to do so:
http://sourceware.org/ml/cygwin-announce/2011-02/msg00027.html
> 4. This version of bash has a cygwin-specific set option, named "igncr",
> to force bash to ignore \r, independently of cygwin's mount style. As
> of bash-3.2.3-5, it controls regular scripts, command substitution, and
> sourced files. I hope to convince the upstream bash maintainer to
> accept this patch into a future bash release even on Linux, rather than
> keeping it a cygwin-specific patch, but only time will tell. There are
> several ways to activate this option:
> 4a. For a single affected script, add this line just after the she-bang:
> (set -o igncr) 2>/dev/null && set -o igncr; # comment is needed
> 4b. For a single script, invoke bash explicitly with the option, as in
> 'bash -o igncr ./myscript' rather than the simpler './myscript'.
> 4c. To affect all scripts, export the environment variable BASH_ENV,
> pointing to a file that sets the shell option as desired. Bash will
> source this file on startup for every script.
> 4d. Added in the bash-3.2-2 release: export the environment variable
> SHELLOPTS with igncr included in it. It is read-only from within bash,
> but you can set it before invoking bash; once in bash, it auto-tracks
> the current state of 'set -o igncr'. If exported, then all bash child
> processes inherit the same option settings; with the exception added in
> 3.2.9-11 that certain interactive options are not inherited in
> non-interactive use.
> 4e. bash-4.1.9-1 dropped support for 'shopt -s igncr'; it did not make
> sense to support the option through both set and shopt, and SHELLOPTS
> proved to be more powerful.
--=20
Eric Blake eblake AT redhat DOT com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
--------------enig117476E124367C5E236978DD
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBCAAGBQJPmV54AAoJEKeha0olJ0NqTn8H/jPf8m+Qbt2Nfiw/02CXmJGF
0a82lbX+lCuUvis5xGIe6WW+PWvJzsB+L6VH3GoSmJy3UtaEIMmCI6YP8vdCm6XW
wrbVWt+TYO7kXhqsw3Hnf6yGOCdhzvCxNRRPwpX9rt3rGs1YxnIamrJedM7AoGgT
bUDg7Ey9GtQ/rApWA/+NQAxPo6KN69dpA3JtktGHpzG7pTgz732Gi3IhwTT9m2Vl
AFX5uG2VvRm0KIxL32aeclkqt5ndghpB1DQva7L/rlX7FfOpf3VdxVxpoA3K6jvz
8+0ay5gTJBKfd/LuufDiqPTv96babu0AbubC/g7Z1pQISXoaNrgqd9DKV6tgJyY=
=s4kV
-----END PGP SIGNATURE-----
--------------enig117476E124367C5E236978DD--
- Raw text -