From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] Why fakeroot works without #! (basically, RTFM)
Date: Thu, 9 Jun 2016 23:36:46 +0200 [thread overview]
Message-ID: <20160609213646.GD3826@free.fr> (raw)
In-Reply-To: <2951546.bZKNuKFtLY@laclwks004>
Brian, All,
On 2016-06-08 12:08 +0200, Brian Foster spake thusly:
> I happened to notice in very recent commit 974e83a8f9a1
> ("fs: add sha-bang to fakeroot script") the comment:
>
> ? We [are] directly running this script, so it should start
> with a sha-bang (not sure why/how it works today...). ?
Oh, someone does read commit logs! :-)
> What is running the (generated) fakeroot script being talked
> about is the the Host script .../usr/bin/fakeroot, which is a
> GNU bash script. The answer then is in ??COMMAND EXECUTION'
> of the bash(1) manual page:
>
> ? If [the exec()] fails because the file is not in executable
> format, and the file is not a directory, it is assumed to be
> a shell script, a file containing shell commands. A subshell
> is spawned to execute it. [...] ?
Well, this was a part of the bash manpage I was not familiar with.
Thanks!
> Or in other words, the traditional Unix shell behaviour of:
> If exec() failed with errno ENOEXEC on a plain file, Then
> assume it is a script written in the language of the shell
> trying to run the script, and run it in a subshell.
Meh, that's so dangerous...
> As an aside, that means the commit 974e83a8f9a1 has changed the
> semantics. The generated fakeroot script used to always be run
> by the GNU bash shell, but now it is run by `/bin/sh' which may
> not be bash (e.g., on my system, it is dash(1)). However, this
> _probably_ does not matter, since, as I recall, POSIX(?) requires
> `/bin/sh' to implement the Bourne shell language, which is what
> the generated script uses, and what both dash and bash provide.
Yes, POSIX mandates that /bin/sh be a bourne shell.
And the script we generate is expected to be POSIX-compliant, i.e. it
should not be using bashisms. So /bin/sh is the correct shell to use.
If we were to use bahsisms in the future, we'd have to change that to
bash, yes.
Thanks for the explanations!
Regards,
Yann E. MORIN.
> cheers!
> -blf-
>
> --
> Brian Foster
> Principal MTS, Software | La Ciotat, France
> Maxim Integrated | http://www.maximintegrated.com/
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
prev parent reply other threads:[~2016-06-09 21:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 10:08 [Buildroot] Why fakeroot works without #! (basically, RTFM) Brian Foster
2016-06-09 21:36 ` Yann E. MORIN [this message]
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=20160609213646.GD3826@free.fr \
--to=yann.morin.1998@free.fr \
--cc=buildroot@busybox.net \
/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