From: Scott Smith <grimblefritz@gmail.com>
To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>
Subject: Re: bash shell script: recently running, now failing
Date: Thu, 6 Apr 2023 08:23:43 -0400 [thread overview]
Message-ID: <CAGHQO_7SJPksHQU2mNa9_UBjWdVi5wQDmxyCBnougynsJzWAgA@mail.gmail.com> (raw)
In-Reply-To: <ZC58y18KZCSQOnP9@calimero.vinschen.de>
[-- Attachment #1: Type: text/plain, Size: 2284 bytes --]
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
>
next prev parent reply other threads:[~2023-04-06 12:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 4:43 Fergus Daly
2023-04-06 8:03 ` Corinna Vinschen
2023-04-06 12:23 ` Scott Smith [this message]
2023-04-06 12:21 ` Andrey Repin
2023-04-07 19:34 ` Brian Inglis
2023-04-08 8:37 ` Andrey Repin
2023-04-06 17:18 ` Adam Dinwoodie
2023-04-06 19:26 ` Scott Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGHQO_7SJPksHQU2mNa9_UBjWdVi5wQDmxyCBnougynsJzWAgA@mail.gmail.com \
--to=grimblefritz@gmail.com \
--cc=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).