Re: More than 10% of all Fedora spec files are not POSIX sh compliant

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

 



On Mon, Mar 25, 2019 at 4:27 PM Stephen John Smoogen <smooge@xxxxxxxxx> wrote:
>
> On Mon, 25 Mar 2019 at 11:18, Kevin Fenzi <kevin@xxxxxxxxx> wrote:
> >
> > On 3/25/19 8:02 AM, Adam Williamson wrote:
> > > On Mon, 2019-03-25 at 12:59 +0100, Dridi Boukelmoune wrote:
> > >> And since RPM appears to be configurable for the
> > >> default interpreter, have it use /usr/bin/bash by default.
> > >
> > > TBH, it seems to me reasonable that we just do this.
> > >
> > > If our position is that we actually expect Fedora package scriptlets to
> > > be executed by bash and don't think it's a problem if they don't work
> > > when executed by some other shell, why not this make this clear and
> > > explicit in this way instead of having the default be sh, but then tell
> > > people sh must be bash?
> >
> > Doesn't bash behave slightly differently when invoked as 'sh' ?
> >
> > Long ago it used to, but I don't know if thats still the case...
> >
>
> It will interpret some things differently but does not shut off things
> like pushd/popd and $() and various other things that are either
> considered non-POSIX

But but... $() is in POSIX sh! Don't refrain from using that one! :D

It's rather things like custom `set -...` options, custom builtins,
associative arrays... Bash in POSIX mode doesn't enforce a strict
POSIX sh syntax:

$ cat test.sh
a=(a b c)
echo ${#a[@]}
$ bash test.sh
3
$ bash --posix test.sh
3
$ dash test.sh
test.sh: 1: test.sh: Syntax error: "(" unexpected

> Man page:
>
>       If  bash  is  invoked  with  the name sh, it tries to mimic the startup
>        behavior of historical versions of sh as  closely  as  possible,  while
>        conforming  to the POSIX standard as well.  When invoked as an interac‐
>        tive login shell, or a non-interactive shell with the  --login  option,
>        it  first  attempts  to read and execute commands from /etc/profile and
>        ~/.profile, in that order.  The  --noprofile  option  may  be  used  to
>        inhibit  this  behavior.  When invoked as an interactive shell with the
>        name sh, bash looks for the variable ENV, expands its value  if  it  is
>        defined,  and uses the expanded value as the name of a file to read and
>        execute.  Since a shell invoked as sh does not attempt to read and exe‐
>        cute  commands from any other startup files, the --rcfile option has no
>        effect.  A non-interactive shell invoked with  the  name  sh  does  not
>        attempt  to  read  any  other  startup files.  When invoked as sh, bash
>        enters posix mode after the startup files are read.
>
>        When bash is started in posix mode, as with the  --posix  command  line
>        option, it follows the POSIX standard for startup files.  In this mode,
>        interactive shells expand the ENV variable and commands  are  read  and
>        executed  from  the  file  whose  name is the expanded value.  No other
>        startup files are read.
>
> ====
> The argument of where posix conformity ends and where adding features begins.
>
>
> > kevin
> >
> >
> >
> > _______________________________________________
> > devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
> > To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
> > Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
> > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> > List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
>
>
>
> --
> Stephen J Smoogen.
> _______________________________________________
> devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
> Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux