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

Re: shebang (was Re: systemd - some more considerations)



Hi,

Thorsten Glaser:
> tglase@tglase:~ $ cat x
> #?/usr/bin/python
> import sys
> print sys.version
> tglase@tglase:~ $ ls -l x
> -rwxr-xr-x 1 tglase tglase 47 Apr  4 12:54 x
> tglase@tglase:~ $ ./x
> import.im6: unable to grab mouse ': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9047.
> sys.version
> tglase@tglase:~ $ b/mksh
> tglase@tglase:~ $ ./x
> 2.7.6 (default, Mar 22 2014, 17:40:27) 
> [GCC 4.8.2]
> 
This just says that mksh handles #! scripts like no other shell.
Doesn't mean that it's a good (or bad) idea.

In fact, I wonder whether anything would break if we removed the ability
to run shebang-less scripts from our shells.

Currently, they do this:

* bash opens the script and interprets it
* ash dash immediately execve() /bin/sh with the script
* mksh obviously opens the file and tries to read the #! line, which
  seems pointless because the kernel already did this.

This gets interesting if you point the #! line to something which is not an
executable.

* ash bash dash obviously behave as if the #! line was not there and
  interpret the script.
* mksh reports the ENOEXEC. I actually like that.

-- 
-- Matthias Urlichs

Attachment: signature.asc
Description: Digital signature


Reply to: