Re: [PATCH 1/3] scripts: use #!/usr/bin/env bash shebang instead of #!/bin/bash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx     |
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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux