From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99945 invoked by alias); 26 Mar 2015 15:54:49 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 99931 invoked by uid 89); 26 Mar 2015 15:54:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Mar 2015 15:54:47 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2QFskZr021982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 26 Mar 2015 11:54:46 -0400 Received: from [10.3.113.15] ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2QFskaN011574 for ; Thu, 26 Mar 2015 11:54:46 -0400 Message-ID: <55142BC5.4080209@redhat.com> Date: Thu, 26 Mar 2015 19:05:00 -0000 From: Eric Blake User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: bash-4.3.33-1 fails to execute shell script with CR+LF EOL in text-mounted directory References: <20150326153734.60517.qmail@mx.akamoz.jp> In-Reply-To: <20150326153734.60517.qmail@mx.akamoz.jp> OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WprL4rl5IFHHgWwSqWvCljb2r44u0iocl" X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00467.txt.bz2 --WprL4rl5IFHHgWwSqWvCljb2r44u0iocl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 2798 On 03/26/2015 09:37 AM, smith@cygwin.akamoz.jp wrote: > Dear Cygwin developers: >=20 > It seems that bash-4.3.33(1) handles CR+LF end-of-line in=20 > the shell-script incorrectly, all of the following conditions are met: >=20 > a. the shell-script file is on TEXT-MOUNTED directory, Thanks for the report. I'll have to test this and see if I can spot what is going wrong (I don't normally try text-mount directories). > b. end-of-line style of the file is CR+LF, and Are you absolutely sure that you don't have excess CR in your file? text mounts only treats the CRLF as a single newline, but does not eat lone CR elsewhere in the file. > c. the command in the file includes & (exec-background), > $( ), or `` (command substitutions) >=20 > It works: > d. it is on the binary-mounted directory, and with igncr shell-option, Does igncr make a difference in the text mount directory situation? > e. end-of-line style is LF, or Yeah, if you don't have CR, it doesn't matter whether you are text mount or binary mount. It is only CR that chokes bash, and only if you don't do something like igncr or text mount to hide it. > f. condition c is not met. It seems that &&, | and || work fine, > although I didn't try all of the metachacters and control-constructs. Weird. >=20 > I found it on x86 Cygwin with 64bit Windows environment first, > the same behavior is observed on 32bit Windows environment also. > I've not tried yet on x64 Cygwin with 64bit Windows environment. >=20 > shell-script to test: (WITH CR+LF END-OF-LINE STYLE) > --- 8< ------ 8< ------ 8< ------ 8< ------ 8< --- > #!/bin/bash Please ATTACH the script as a binary file, rather than pasting it inline in your email; or at a bare minimum, show 'od -tx1z yourscript' to make it obvious the exact byte patterns your file contains. Inline text in email does NOT make it obvious what line endings you are intending. >=20 > example of execution, on bash-4.3.33(1): > --- 8< ------ 8< ------ 8< ------ 8< ------ 8< --- > $ LANG=3DC ./test.sh > hoge > ./test.sh: line 3: fuga: command not found > ./test.sh: line 4: piyo: command not found > ./test.sh: line 5: o: command not found > ./test.sh: line 6: ho: command not found > ./test.sh: line 7: cho: command not found > --- 8< ------ 8< ------ 8< ------ 8< ------ 8< --- >=20 > Maybe commands are read from the positions one-byte shifted, line-by-line. Use of & or $() causes bash to fork; maybe the forked child is attempting to lseek back to the position last visited by the parent based on characters read, but failing to account for the fact that lseek on a text-mount file causes issues because characters read is different than file offset advanced? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --WprL4rl5IFHHgWwSqWvCljb2r44u0iocl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 604 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVFCvFAAoJEKeha0olJ0NqgswH/RTz7t3TT4hsLSnoOjHOlMdc vpOc2FiNlzCSjSqviw6EEYHDpYagVmTVF6Gei/rq6bXK6G47ywgs/9vW6H3/D1wL +wBXuliEtuBf4R/5tU2JhRvM+E9/Np2U7mxKOzMW0VXeToVUwHyujt8r6FkXzEXS LVOE9AbPc4iSjzKTLUMu9eMSRCd8T66F2S3BhCx9+0hWIzz/xIZp5KFm39nfhZdF 4u3AGTJk7m2GwRpFZ+vEF0lpF0YNU6Ut1VwqTBKDTIIbsVGMrpU1xD2qCMHd/JpI FljUlyVcN2lqzWb+AK3rOq2uzbq5kqzqr9+6hPaeBG4Nl6w1JdjcuEHzT1Kk+OQ= =F+xG -----END PGP SIGNATURE----- --WprL4rl5IFHHgWwSqWvCljb2r44u0iocl--