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

2014-04-04 Thread Matthias Urlichs
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


signature.asc
Description: Digital signature


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

2014-04-04 Thread Andrey Rahmatullin
On Fri, Apr 04, 2014 at 02:04:32PM +0200, Salvo Tomaselli wrote:
> > > Sure. I’ve patched mksh 
> > 
> > mksh doesn't count as a reference.
> Did you even read before replying? He patched it to use #? Instead of #! that 
> was using.
> He was sure about it being there because he had patched it to behave 
> differently.
And all of that was to prove mksh does something, which cannot be used as
an argument about general or standardized behavior, or something.

-- 
WBR, wRAR


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140404122721.ga29...@belkar.wrar.name



Re: shebang

2014-04-04 Thread Andrey Rahmatullin
On Fri, Apr 04, 2014 at 02:00:46PM +0200, Thorsten Glaser wrote:
> > I'm interested where POSIX says what you are sure it says (that the
> > shell is responsible for evaluating #!).
> 
> I said the shell is supposed to, and suggested to search POSIX, but
> I wasn’t sure that it was POSIX standardised, and never said so. As
> you cited, it’s probably not. Doesn’t mean the shell doesn’t or
> shouldn’t.
Can you please refrain from asking to "search something" when you are not
sure something even exists?

> > > Also, “man mksh” look for EXECSHELL (which is the interpreter the
> > > shell uses if the script doesn’t even have a shebang).
> >
> > I don't think the manual for a not commonly used shell is a good
> > reference...
> 
> Uhm, excuse me?
> 
> “Larry Page: 1.5 million Android devices activated every day”
> “Android device activations set to hit 1 billion soon”
> ‣ 
> http://www.androidcentral.com/larry-page-15-million-android-devices-activated-every-day
> That was on 2013-07-18; by that time, every new device activation
> meant one new mksh user.
> 
> “Google announced that in Q3 2011, the total number of Android
> activations had surpassed 190 million, which was a significant increase
> from 135 million the previous quarter. The increase was boosted by sales
> of Android smartphones at lower prices from Chinese and Indian
> manufacturers.[2] As of 3 September 2013, there have been 1 billion
> Android devices activated.[3]”
> ‣ https://en.wikipedia.org/wiki/Comparison_of_Android_devices
> Every 4.x device, and many others, run mksh as system shell
> (/system/bin/sh, Android’s equivalent of our /bin/sh).
> 
> According to the graphics at
> https://en.wikipedia.org/wiki/File:Android_historical_version_distribution_-_vector.svg
> that’s over ¾ of all devices (although the graphics is unclear as to
> whether that is the total number of all activations, or (as seems to
> be common with statistics from Google) the number of currently “live”
> devices). Add to that the amount of devices running AOSP or another
> non-phone-home firmware (Replicant, maybe SiMKo3, Cyanogen… well it
> does phone home…).
> 
> There are also hundreds of Debian (or derivates) systems running
> with mksh as /bin/sh (I should know, I set up a good part of them).
> 
> All FreeWRT, MidnightBSD, MirBSD, and recent OpenADK systems run
> with mksh as system shell (/bin/sh); sta.li will do that too.
> 
> There’s also a lot of systems that c̲a̲n̲ run with mksh as system shell
> at the administrator’s choice. Debian, all BSDs (NetBSD® only from
> version 1.6 onwards, 1.5 has ashisms in the init scripts), Crux,
> FreeMiNT, Deli Linux, etc. at least.
> 
> And only then add the sheer amount of systems where mksh is used
> but not as system shell…
> 
> I honestly doubt that any other Unix shell is currently used as
> widespread as mksh.
Doesn't make it more authoritative or something.

-- 
WBR, wRAR


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140404122318.ga29...@belkar.wrar.name



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

2014-04-04 Thread Salvo Tomaselli
In data venerdì 04 aprile 2014 17.38.12, Andrey Rahmatullin ha scritto:
> > Sure. I’ve patched mksh 
> 
> mksh doesn't count as a reference.
Did you even read before replying? He patched it to use #? Instead of #! that 
was using.
He was sure about it being there because he had patched it to behave 
differently.

-- 

Salvo Tomaselli

"Io non mi sento obbligato a credere che lo stesso Dio che ci ha dotato di
senso, ragione ed intelletto intendesse che noi ne facessimo a meno."
-- Galileo Galilei

http://ltworf.github.io/ltworf/


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/2629335.D8GMTTWuuY@vulcano



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

2014-04-04 Thread Jakub Wilk

* Thorsten Glaser , 2014-04-04, 12:58:

Try duckduckgoïng instead ☻ or searching POSIX, or something.


SUSv4 “helpfully” says:

If the first line of a file of shell commands starts with the characters 
"#!", the results are unspecified.


--
Jakub Wilk


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140404114816.ga3...@jwilk.net



Re: shebang

2014-04-04 Thread Thorsten Glaser
On Fri, 4 Apr 2014, Ansgar Burchardt wrote:

> I'm interested where POSIX says what you are sure it says (that the
> shell is responsible for evaluating #!).

I said the shell is supposed to, and suggested to search POSIX, but
I wasn’t sure that it was POSIX standardised, and never said so. As
you cited, it’s probably not. Doesn’t mean the shell doesn’t or
shouldn’t.

> > Also, “man mksh” look for EXECSHELL (which is the interpreter the
> > shell uses if the script doesn’t even have a shebang).
>
> I don't think the manual for a not commonly used shell is a good
> reference...

Uhm, excuse me?

“Larry Page: 1.5 million Android devices activated every day”
“Android device activations set to hit 1 billion soon”
‣ 
http://www.androidcentral.com/larry-page-15-million-android-devices-activated-every-day
That was on 2013-07-18; by that time, every new device activation
meant one new mksh user.

“Google announced that in Q3 2011, the total number of Android
activations had surpassed 190 million, which was a significant increase
from 135 million the previous quarter. The increase was boosted by sales
of Android smartphones at lower prices from Chinese and Indian
manufacturers.[2] As of 3 September 2013, there have been 1 billion
Android devices activated.[3]”
‣ https://en.wikipedia.org/wiki/Comparison_of_Android_devices
Every 4.x device, and many others, run mksh as system shell
(/system/bin/sh, Android’s equivalent of our /bin/sh).

According to the graphics at
https://en.wikipedia.org/wiki/File:Android_historical_version_distribution_-_vector.svg
that’s over ¾ of all devices (although the graphics is unclear as to
whether that is the total number of all activations, or (as seems to
be common with statistics from Google) the number of currently “live”
devices). Add to that the amount of devices running AOSP or another
non-phone-home firmware (Replicant, maybe SiMKo3, Cyanogen… well it
does phone home…).

There are also hundreds of Debian (or derivates) systems running
with mksh as /bin/sh (I should know, I set up a good part of them).

All FreeWRT, MidnightBSD, MirBSD, and recent OpenADK systems run
with mksh as system shell (/bin/sh); sta.li will do that too.

There’s also a lot of systems that c̲a̲n̲ run with mksh as system shell
at the administrator’s choice. Debian, all BSDs (NetBSD® only from
version 1.6 onwards, 1.5 has ashisms in the init scripts), Crux,
FreeMiNT, Deli Linux, etc. at least.

And only then add the sheer amount of systems where mksh is used
but not as system shell…

I honestly doubt that any other Unix shell is currently used as
widespread as mksh.

bye,
//mirabilos
-- 
«MyISAM tables -will- get corrupted eventually. This is a fact of life. »
“mysql is about as much database as ms access” – “MSSQL at least descends
from a database” “it's a rebranded SyBase” “MySQL however was born from a
flatfile and went downhill from there” – “at least jetDB doesn’t claim to
be a database”  ‣‣‣ Please, http://deb.li/mysql and MariaDB, finally die!


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/alpine.deb.2.10.1404041350070.25...@tglase.lan.tarent.de



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

2014-04-04 Thread Ansgar Burchardt
Hi,

Thorsten Glaser  writes:
> On Fri, 4 Apr 2014, Chow Loong Jin wrote:
>
>> Are you sure about this?
>
> Yes.
>
>> Some references would be helpful. I can't seem to find anything on this 
>> through
>
> Sure. I’ve patched mksh to use “#?” ipv “#!” as shebang, to
> simulate a kernel not supporting the shebang:
[...]
> Try duckduckgoïng instead ☻ or searching POSIX, or something.

I tried and found that POSIX says the shell shall try execve(), and if
that fails 'the shell shall execute a command equivalent to having a
shell invoked with the pathname resulting from the search as its first
operand, with any remaining arguments passed to the new shell, except
that the value of "$0" in the new shell may be set to the command
name.'[1] No #! involved.

  [1] 


Furthermore Wikipedia says "For this reason and because POSIX does not
standardize path names, POSIX does not standardize the feature."[2].

  [2] 

I'm interested where POSIX says what you are sure it says (that the
shell is responsible for evaluating #!).

> Also, “man mksh” look for EXECSHELL (which is the interpreter the
> shell uses if the script doesn’t even have a shebang).

I don't think the manual for a not commonly used shell is a good
reference...

Ansgar


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/87ha69xqyj@deep-thought.43-1.org



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

2014-04-04 Thread Andrey Rahmatullin
On Fri, Apr 04, 2014 at 12:58:23PM +0200, Thorsten Glaser wrote:
> > Are you sure about this?
> 
> Yes.
> 
> > Some references would be helpful. I can't seem to find anything on this 
> > through
> 
> Sure. I’ve patched mksh 
mksh doesn't count as a reference.

> > some cursory googling.
> Try duckduckgoïng instead ☻ or searching POSIX, or something.
That's quite helpful.

-- 
WBR, wRAR


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140404113812.ga27...@belkar.wrar.name