mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: Florian Klink <flokli@flokli.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] scripts: use #!/usr/bin/env bash shebang instead of #!/bin/bash
Date: Tue, 3 Dec 2019 13:50:02 +0100	[thread overview]
Message-ID: <20191203125002.tckomqfydc5tlmrc@pengutronix.de> (raw)
In-Reply-To: <20191203064603.63puhjwyoeaagba5@pengutronix.de>

On Tue, Dec 03, 2019 at 07:46:03AM +0100, Michael Olbrich wrote:
> On Thu, Nov 28, 2019 at 12:19:44AM +0100, Florian Klink wrote:
> > Some distributions might not have bash in /bin, but in $PATH.
> > 
> > Using #!/usr/bin/env bash solves this, and is consistent with how the
> > perl and python shebangs look like in the tree.
> > ---
> >  scripts/canon-a1100-image        | 2 +-
> >  scripts/check_size               | 2 +-
> >  scripts/dfuboot.sh               | 2 +-
> >  scripts/extract_symbol_offset    | 2 +-
> >  scripts/gen-dtb-s                | 2 +-
> >  scripts/genenv                   | 2 +-
> >  scripts/socfpga_get_sequencer    | 2 +-
> >  scripts/socfpga_import_preloader | 2 +-
> >  scripts/socfpga_xml_to_config.sh | 2 +-
> >  9 files changed, 9 insertions(+), 9 deletions(-)
> > 
> > diff --git a/scripts/canon-a1100-image b/scripts/canon-a1100-image
> > index 6c08d7493..237ce26d8 100755
> > --- a/scripts/canon-a1100-image
> > +++ b/scripts/canon-a1100-image
> > @@ -1,4 +1,4 @@
> > -#!/bin/bash -e
> > +#!/usr/bin/env bash -e
> 
> This does not work:
> 
> /usr/bin/env: ‘bash -e’: No such file or directory
> /usr/bin/env: use -[v]S to pass options in shebang lines
> 
> Using '/usr/bin/env -S bash -e' works, but I'm not sure how portable that
> is.

According to execve(2) [1], this behaviour is specific to Linux:

       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.

So /usr/bin/env apparently does some argument splitting itself when
called with -S.

[1]: http://man7.org/linux/man-pages/man2/execve.2.html#NOTES

 - Roland

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-12-03 12:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27 23:19 use /usr/bin/env bash shebang instead of /bin/bash Florian Klink
2019-11-27 23:19 ` [PATCH 1/3] scripts: use #!/usr/bin/env bash shebang instead of #!/bin/bash Florian Klink
2019-12-03  6:46   ` Michael Olbrich
2019-12-03  8:45     ` Sascha Hauer
2019-12-03  9:12       ` Michael Olbrich
2019-12-05 21:45         ` [PATCH v2 1/4] " Florian Klink
2019-12-05 21:45           ` [PATCH v2 2/4] dts/scripts: " Florian Klink
2019-12-05 21:45           ` [PATCH v2 3/4] docs: " Florian Klink
2019-12-05 21:45           ` [PATCH v2 4/4] docs: use #!/usr/bin/env python shebang instead of #!/usr/bin/python Florian Klink
2019-12-06 11:31           ` [PATCH v2 1/4] scripts: use #!/usr/bin/env bash shebang instead of #!/bin/bash Roland Hieber
2019-12-06 12:32             ` use #!/usr/bin/env binary instead of #!/usr/bin/binary Florian Klink
2019-12-06 12:32               ` [PATCH v3 1/4] scripts: use #!/usr/bin/env bash shebang instead of #!/bin/bash Florian Klink
2019-12-06 12:32               ` [PATCH v3 2/4] dts/scripts: " Florian Klink
2019-12-06 12:32               ` [PATCH v3 3/4] docs: " Florian Klink
2019-12-06 12:32               ` [PATCH v3 4/4] docs: use #!/usr/bin/env python shebang instead of #!/usr/bin/python Florian Klink
2019-12-06 14:25               ` use #!/usr/bin/env binary instead of #!/usr/bin/binary Sascha Hauer
2019-12-03 12:50     ` Roland Hieber [this message]
2019-11-27 23:19 ` [PATCH 2/3] dts/scripts: use #!/usr/bin/env bash shebang instead of #!/bin/bash Florian Klink
2019-11-27 23:19 ` [PATCH 3/3] docs: " Florian Klink
2019-12-02  8:57 ` use /usr/bin/env bash shebang instead of /bin/bash Sascha Hauer
2019-12-02 14:29   ` Florian Klink

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=20191203125002.tckomqfydc5tlmrc@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=flokli@flokli.de \
    /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