X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C485E3858291
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1680783853;
	bh=OXbeDgxE7WjCKgR5VZe0l1y4TNAAV/ETHjtgkP2gFQk=;
	h=References:In-Reply-To:Date:Subject:To:Cc:List-Id:
	 List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
	 From:Reply-To:From;
	b=rsKZehqSFamFydvN+HNbfBsDavB1p4ZbUKfBUstdsmGuH26aaS6s2DhxaaAEv7QyO
	 oREnt9NA6Le5o2158XBiYMz80cWDkwj2ASNUrLjE56X7DwGU9/TOPwqAR7v6SylgZ7
	 ok1wgwSS31zBhAylhdQy9pptz04vfuFCPc/qLHB4=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E8003858D32
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112; t=1680783835; x=1683375835;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=UhnfIUIkAdXRAJwr6y7OkO383n8bKvP3XWYy5vgn+uU=;
 b=JKEtDmuOierw2iX8F/peqGbGIdIByBNfcUNoYdHna56Dtpkgi1BlFeWGcSQamphFDu
 N6TI26tqHgL60EjQjsZToZL2Ff/sWZq8GVAE262P9tuyN2geigrPg4+WUG1OOsW73mly
 WgEMguFKAzAuhVqYOClTIFirJ8uvsuK5Xec38TCePkRFIFfVLeMbaT9MfJ/97H8HACsi
 XEXQ6YJdThwSAGCRCxJB5Dn7A3cMU46fqz84JPdo8xBoZDReLgoRLc6U/WLgJBe8DXSx
 5rj6QnSBTMhuwhSJhGVjBuTIpE17m6FdReXrUtPrZwmVXt1YNPbuVTrZfZK8IKpSkXuS
 v1tA==
X-Gm-Message-State: AAQBX9f5TbyfkYxgR/3rsLmJm1J1xDI8J9gyfNR8gBDQTFM42f0s/pnL
 GXvvU5LiUTTMM5J6Nv/HyS8R5DQIJR5Qo10ZUPBW7VdV
X-Google-Smtp-Source: AKy350Y/KYchHSeh9olC+oRngCJdfcMvVopb9AnEpDOhlGBROZzyHZIPcxB99DlUMtQtiDwGm9PPANTQiI8QuMYYy2U=
X-Received: by 2002:aa7:d79a:0:b0:502:3376:46bc with SMTP id
 s26-20020aa7d79a000000b00502337646bcmr4520942edq.8.1680783834664; Thu, 06 Apr
 2023 05:23:54 -0700 (PDT)
MIME-Version: 1.0
References: <DB6P18901MB005559D81FD4125B0D6DAA07A4919@DB6P18901MB0055.EURP189.PROD.OUTLOOK.COM>
 <ZC58y18KZCSQOnP9@calimero.vinschen.de>
In-Reply-To: <ZC58y18KZCSQOnP9@calimero.vinschen.de>
Date: Thu, 6 Apr 2023 08:23:43 -0400
Message-ID: <CAGHQO_7SJPksHQU2mNa9_UBjWdVi5wQDmxyCBnougynsJzWAgA@mail.gmail.com>
Subject: Re: bash shell script: recently running, now failing
To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>
X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE,
 RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS,
 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
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Scott Smith via Cygwin <cygwin@cygwin.com>
Reply-To: Scott Smith <grimblefritz@gmail.com>
Content-Type: text/plain; charset="utf-8"
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 336COeRj031016

Place the nul on the third line. For example:

#!/bin/bash
#
# ^@ identify as a binary file
...



On Thu, Apr 6, 2023 at 4:03 AM Corinna Vinschen via Cygwin <
cygwin@cygwin.com> wrote:

> 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
>
> --
> Problem reports:      https://cygwin.com/problems.html
> FAQ:                  https://cygwin.com/faq/
> Documentation:        https://cygwin.com/docs.html
> Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
>

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

