From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25764 invoked by alias); 1 May 2014 06:41:41 -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 25746 invoked by uid 89); 1 May 2014 06:41:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS 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 ESMTP; Thu, 01 May 2014 06:41:39 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s416fbeg025669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 May 2014 02:41:38 -0400 Received: from [10.3.113.132] (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s416fbUW031906 for ; Thu, 1 May 2014 02:41:37 -0400 Message-ID: <5361ECA1.1040302@redhat.com> Date: Thu, 01 May 2014 06:41:00 -0000 From: Eric Blake User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: cygwin-bash compat/regression bug... startup line prob References: <535EBD61.5080109@tlinx.org> <535EC59E.9080602@redhat.com> <5361E22D.40408@tlinx.org> In-Reply-To: <5361E22D.40408@tlinx.org> OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kaPg0LDRunfNvPCa73M064ScrXcH3Bj9P" X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg00006.txt.bz2 --kaPg0LDRunfNvPCa73M064ScrXcH3Bj9P Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-length: 4169 On 04/30/2014 11:57 PM, Linda Walsh wrote: > Eric Blake wrote: >> On 04/28/2014 02:43 PM, Linda Walsh wrote: >> >> >> cat bin/t.sh >> > #!/bin/bash -u=20 > Um... it doesn't work with 1 argument either. Your context quoting is hard to follow. Here, you are complaining about a she-bang with only one argument,... >> >> This is an invalid shebang line. Historically, you are allowed at most >> ONE argument to the program that you will be executing. > ?!? Historically?.. since when? Never encountered that problem on linux > nor on cygwin. This isn't a case of 2 args, just the "-u" by itself > doesn't work. ...but here, you are quoting my reply to your original example that included two arguments, although you managed to snip that original text [for reference, my comment was about _this_ portion of your mail: | > cat bin/t.sh | #!/bin/bash -u -x which is indeed invalid usage]. I made no comment confirming or denying whether your use of '-u' by itself works (as I was not on cygwin when I wrote my first reply, and so had no easy way to confirm or refute if one-argument -u "works" on cygwin); but was merely pointing out that in your further investigation of the issue, you were creating an unsupported 2-argument she-bang line, and thus not testing what you thought you were testing. As for history of shebang, https://en.wikipedia.org/wiki/Shebang_%28Unix%29 states that whether subsequent arguments are split (Solaris) or provided as one argument (Linux) has been a long time issue, quoting at least this article from 2008 http://mail-index.netbsd.org/netbsd-users/2008/11/09/msg002388.html, although I'm sure you could trace it back at least to the 1980s. The Linux man pages for execve state: A maximum line length of 127 characters is allowed for the first line in a #! executable shell script. The semantics of the optional-arg argument of an interpreter script vary across implementations. On Linux, the entire string following the interpreter name is passed as a single argument to the interpreter, and this string can include white space. However, behavior differs on some other systems. Some systems use the first white space to terminate optional-arg. On some systems, an interpreter script can have multiple arguments, and white spaces in optional-arg are used to delimit the arguments. Since cygwin emulates Linux, it makes sense that Cygwin likewise accepts exactly one argument on the shebang line. >=20 >> > Also weird -- the interp line says "/bin/bash" not "/usr/bin/bash" >> > as the shell, so why does the error come from /usr/bin/bash? >> >> the answer to this question. > --- > ??? > This isn't clear to me. If I am running /bin/bash, why did the error > message > say /usr/bin/bash? >=20 Because you weren't running /bin/bash at that point in time, but /usr/bin/bash. Again, you snipped the relevant portion of your original mail: | > bash t.sh but that says to run 't.sh' using the 'bash' interpreter found first in your PATH (which presumably had /usr/bin before /bin), and not as a standalone executable. A shebang line is ignored when you run a script directly as an argument to 'bash' - the only time a shebang line is honored is when it appears as argv[0] of the execve() family of functions (your command line had it as argv[1]). To use the shebang, you have to execute 't.sh', not 'bash t.sh'. Remember, when bash executes a script, the #! line is a comment that does not further impact how bash behaves. (If you look at the bash source code, it does have fallback code to emulate shebang magic on platforms where execve() fails due to lacking shebang support. But there are two things to note - this fallback does NOT kick in on cygwin, since cygwin's execve() DOES have shebang support; and even with that fallback code in bash, it is still only triggered in instances where you try to execute a script as argv[0] of the child process, and NOT when you pass the script name as argv[1] of the bash process.) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kaPg0LDRunfNvPCa73M064ScrXcH3Bj9P 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/ iQEcBAEBCAAGBQJTYeyhAAoJEKeha0olJ0NqCoAIAJoJ2z/n/XdBt9vOO4gUKTY7 C2rrXiaML8wBJctzXpEfLbFB2qYhOzDGxS+1Lp24L1mgMZ/09hSNcM98MgABc5m8 rmJrlVGJL2MQL+IsyItWXOcxC0jxSKRM/wdgeubjrhyb8o3Ju1a9jp6ZjwJRmwOy HLRMv4rWkTaIdgsy8s7wDB/oWXvSrfYveqHEbitl8Bsr7J5UkirDL9qWePP6luut 9bnlCbbaAdmiinxXK/+QxEMnkTU7FDjqYKq4MP4IBNPCPuH4HC1Zd42w9sxm8KMw t2IY3aOkTN+ABpxraBhMxbQM2f1DhkiTP8EkbByBG0AJmSi8v3FhCCDMp3+fWgU= =OT6J -----END PGP SIGNATURE----- --kaPg0LDRunfNvPCa73M064ScrXcH3Bj9P--