From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by sourceware.org (Postfix) with ESMTPS id EF41F3858D32 for ; Thu, 6 Apr 2023 08:03:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF41F3858D32 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MZTyo-1pvl2z2k7S-00WX5w for ; Thu, 06 Apr 2023 10:03:23 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 27ED8A80C68; Thu, 6 Apr 2023 10:03:23 +0200 (CEST) Date: Thu, 6 Apr 2023 10:03:23 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: bash shell script: recently running, now failing Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:pEneop/GmZmYQ/RXaoWL8z9vgmBPVaBeGtntlXlug7AbvQMzmdw VnsNF+d8Jb55ZAAgmG/6mfq29Ov1bBd1VqbAfIx2ZWPLC/uD+B+uknys9o9WWcDVdogd5iw yolyInHL1CM4FZLr73WKwFmluDx1SUu9KjCLCorm0NlnRcLDfv5hEjiBAtTpjv888fUc/RE faL0kCX4MDo293Shz1ldg== UI-OutboundReport: notjunk:1;M01:P0:tuCn2Bmj8EA=;pcaNkc6CivUIAkOM+SLQcfja/AD I+sRvFHNRt0P4IsVUFIrPLBgmAgtY0mUbjSlk6sAxyVewz5JumWOSljbyFGwJ4huw8Ar7RaMO wwTFNWw1bNdGxnpcOTHtAToCySWWlZdBQCVC+gPmhJCJAlRd2it9MeE/OIAwZWZKCaOvItcSG VEXhNDjhnQnn6lpaG2+nIpvZi7kqYEYsJmXKhz18hcp/me6nMebEnFDuMnsK0LXG5/m/xy/z8 k2XEG9JXBBlVn6Kkg0mayybBzrMUcKDUPIyXtrZG36NNMsruU8edqRy9/sPVBMvJb2JYwdV+a AmsvnNPUiFKlWRh4spBKkfv25y0QqSYDCfPTZNVbrbX7O5nJrNp05tlxY7ABE6ThOerItFbce zKRYDMEJOBzoICDIGEpywjXBvRsCvU1loI+rRWgluUlgNWnh1cc3832chYWaMOgsJ8wOHXQJx yX7ixUGe8B+h4TQzu9XHkPW756eguWRXFG/l4a7+mjULlzkzxuexDarS2rKbX/M65qvPN36oP DWF28K8TR9GMvLyaq1UkHGI4OjuU/ZmZTs/V2cxsj22bk96Dq0g8NnQuy7Lv6y0G6Wm5BFoFX pU+p83xrLlXh/FV6aUELQYbHfKUtrX+MGtMu/tMv0KKetjZD/9hgitpLEwL+cU30YM3Ax7/J1 HE+tqtfqu5hFexNw8lVaKSp6RkRvgncb3mKHx6Xj8w== X-Spam-Status: No, score=-97.7 required=5.0 tests=BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_FAIL,SPF_HELO_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Apr 6 04:43, Fergus Daly via Cygwin wrote: > I have a "hash bang" bash shell script i.e. first line > #! /bin/sh > or equivalently > #! /bin/bash > For various reasons I want this file to be identified as binary so its second line > is the single character null \x00 showing up in some editors e.g. nano as > ^@ > This does not prevent the script from running to a successful conclusion. > Or not until recently. Now the script fails with > /home/user/bin/file.old.sh: cannot execute binary file > Q1 - was bash recently updated? Would this explain the changed behaviour? bash was recently updated from 4.4.12 to 5.2.15. The behaviour is the same in bash on Linux. Take this file with a \0 in line 2: $ cat -v x.sh #! /bin/bash ^@ echo foo $ bash --version | head -1 GNU bash, version 5.2.15(1)-release (x86_64-redhat-linux-gnu) $ ./x.sh ./x.sh: ./x.sh: cannot execute binary file While dash on Linux runs the script: $ sed -i -e 's/bash/dash/' x.sh $ ./x.sh foo > Q2 - if so, is this newly introduced "glitch" known and presumably > intended? Or an unintended consequence that will be retracted in a > later update? Bash follows the POSIX standard: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_07 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_403 So I don't expect this will change any time soon. > Q3 - at 1/8 the size of bash and sh, I am not at all sure of the role and reach of dash. Dash is a minimal shell with no bells and whistles. It loads ands runs slightly faster than bash. If you only need bare minimum bourne shell behaviour, it's a good choice for scripts. Corinna