From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 8E8003858D32; Thu, 6 Apr 2023 12:23:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E8003858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-50263dfe37dso6128139a12.0; Thu, 06 Apr 2023 05:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680783835; x=1683375835; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UhnfIUIkAdXRAJwr6y7OkO383n8bKvP3XWYy5vgn+uU=; b=cbWEfctSHNEdCGoWjMrBbu7zUH1vS2il8AXlR+xGHYuadeOnup1y14ABN831pjX7yj MiMMQoHbaDhQwMqY2cBbVWIhiierzGEQuCB4Jx8WfUktxvGCsiB+1b2DhWMEnHqzuHTB Q/Wfe53VMVPl6SeF/73xzYcfwSDmaUyhPIjgc6Gm3cVxEpA7j6F8XdqjACnXBU4swwHW rNqGMyC4XPNsw3ltECz6ycrE6IJ8RKOcxB1pVlcFBu+TefWn5ndfyUlJHbBuz5SkRY3b 0Jdojq4zeks6YZ9MHTgGqbK3N+j1bPvYHL582paMw9YF7Jp1a7m3ROp+Oeo7s5lpF1KY T63w== 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: In-Reply-To: From: Scott Smith Date: Thu, 6 Apr 2023 08:23:43 -0400 Message-ID: Subject: Re: bash shell script: recently running, now failing To: cygwin@cygwin.com Cc: Corinna Vinschen Content-Type: multipart/alternative; boundary="00000000000068d2cb05f8a9fb9e" 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 List-Id: --00000000000068d2cb05f8a9fb9e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Place the nul on the third line. For example: #!/bin/bash # # ^@ identify as a binary file ... On Thu, Apr 6, 2023 at 4:03=E2=80=AFAM 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 conclusio= n. > > 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 behaviou= r? > > 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 > --00000000000068d2cb05f8a9fb9e--