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

2019-12-03 Thread Roland Hieber
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.hie...@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- |

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


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

2019-12-03 Thread Michael Olbrich
On Tue, Dec 03, 2019 at 09:45:28AM +0100, Sascha Hauer wrote:
> 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.
> 
> Why not:
> 
> #!/usr/bin/env bash
> 
> set -e

Yes, that should work.

Michael

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


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

2019-12-03 Thread Sascha Hauer
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.

Why not:

#!/usr/bin/env bash

set -e

?

Sascha


-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


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

2019-12-02 Thread Michael Olbrich
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.

Michael

>  
>  IFILE=$1
>  OFILE=$2
> diff --git a/scripts/check_size b/scripts/check_size
> index 8530435d3..76608eccc 100755
> --- a/scripts/check_size
> +++ b/scripts/check_size
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  symbol="$1"
>  file="$2"
> diff --git a/scripts/dfuboot.sh b/scripts/dfuboot.sh
> index 524113b61..9847579ce 100755
> --- a/scripts/dfuboot.sh
> +++ b/scripts/dfuboot.sh
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  DEVICETREE=
>  KERNEL=
> diff --git a/scripts/extract_symbol_offset b/scripts/extract_symbol_offset
> index 78b866830..d0ea22434 100755
> --- a/scripts/extract_symbol_offset
> +++ b/scripts/extract_symbol_offset
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  symbol="$1"
>  file="$2"
> diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
> index b2dd253c2..0649247f9 100755
> --- a/scripts/gen-dtb-s
> +++ b/scripts/gen-dtb-s
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  name=$1
>  dtb=$2
> diff --git a/scripts/genenv b/scripts/genenv
> index 5ebe69963..454f2327b 100755
> --- a/scripts/genenv
> +++ b/scripts/genenv
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  # Generate the default environment file from a list of directories
>  # usage: genenv...
> diff --git a/scripts/socfpga_get_sequencer b/scripts/socfpga_get_sequencer
> index 36f67498b..5405bfa6b 100755
> --- a/scripts/socfpga_get_sequencer
> +++ b/scripts/socfpga_get_sequencer
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  if [ "$#" -lt "2" ]
>  then
> diff --git a/scripts/socfpga_import_preloader 
> b/scripts/socfpga_import_preloader
> index 6c748fadb..23e3c380d 100755
> --- a/scripts/socfpga_import_preloader
> +++ b/scripts/socfpga_import_preloader
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  if [ "$#" -lt "2" ]
>  then
> diff --git a/scripts/socfpga_xml_to_config.sh 
> b/scripts/socfpga_xml_to_config.sh
> index 7e22ebb9e..3bb0dd283 100755
> --- a/scripts/socfpga_xml_to_config.sh
> +++ b/scripts/socfpga_xml_to_config.sh
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  
>  ## TODO:
>  ## - read in mpuclk and nocclk, must be calculated by hand at the moment
> -- 
> 2.24.0
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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