[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/45430: ash uses argv as $0 for scripts without #!
On Wed, Oct 5, 2011 at 9:55 PM, David Laight <david%l8s.co.uk@localhost> wrote:
> This isn't a bug!
> For a normal program binary argv is whatever the user typed, this
> also applies to non #! scripts executed by the shell.
> The execution of #! scripts is done by the kernel which has to
> pass the interpreter the full pathname of the script file.
Sorry, I forgot #! scripts are executed by the kernel for a moment,
while looking for a reason to change this (wishful thinking?).
I agree that this is not strictly a bug from the architecture standpoint.
However, in the user's view this may seem strange and inconsistent and
could be confusing.
Especially considering bash, dash, busybox, zsh, csh, and tcsh (but
not ksh) do supply full path in $0 in that case.
It seems a practical thing to do.
I do, of course, pursue my own goals here.
I need this to work around "peculiar" Android filesystem hierarchy to
have scripts run both on the device and on host.
Details, if anyone is curious:
I could change it in our branch, no problem, or try to convince Google
developers. I just hoped it could be seen by upstream as a useful
thing to have, so I wouldn't have to maintain it :)
If nothing else, could you please confirm that the patch above doesn't
Thank you very much :)
> For suid #! scripts the kernel will pass the name of an open fd
> (as /dev/fd/n) as argv to be absolutely sure the correct file
> is opened (no symlink dances).
> This has the 'odd' side effect that you normally need 'rx' permissions
> to run a #! script - unless it is suid and you aren't the owner, in
> which case 'x' is enough.
Thanks, I didn't know that!
Main Index |
Thread Index |