[packages/mksh] - behave as proper sh when invoked as /bin/sh, wothout fancy, incompatible hacks - rel 2

Jakub Bogusz qboosh at pld-linux.org
Wed Dec 17 21:01:17 CET 2014


On Wed, Dec 17, 2014 at 04:06:23PM +0100, Jan Rękorajski wrote:
> On Wed, 17 Dec 2014, Kacper Kornet wrote:
> 
> > On Tue, Dec 16, 2014 at 11:29:05PM +0100, baggins wrote:
> > > commit e8ed3f0e4ba55966f3aa461d8deb6617f32d106e
> > > Author: Jan Rękorajski <baggins at pld-linux.org>
> > > Date:   Tue Dec 16 23:30:41 2014 +0100
> > 
> > >     - behave as proper sh when invoked as /bin/sh, wothout fancy, incompatible hacks
> > >     - rel 2
> > 
> > This change breaks our rc-scripts:
> > 
> > $ rpm -q mksh
> > mksh-50d-1.x86_64
> > $ /bin/sh -c "echo -en '\n'" 
> > 
> > $ rpm -q mksh
> > mksh-50d-2.x86_64
> > $ /bin/sh -c "echo -en '\n'"
> > -en \n
> > 
> > There was a small discussion about it some time ago:
> > https://lists.pld-linux.org/mailman/pipermail/pld-devel-pl/2011-May/153795.html
> 
> Yea, I fell for it. And disabled {} expansion.
> This 'echo' behavior is broken, totally. It prevents glibc to build for
> x32, some scripts there use '\\n\ and '\n' in echo and expect it to pass
> - every shel just passes it as-is without -e to echo, but not mksh.

If "any" means bash or BSD sh...?

Standard POSIX sh doesn't support any options and always interprets
escapes (though I don't know such shell in practice).
BSD sh supports -e and -n (but not "-ne", which is GNU-specific).
pdksh/mksh support -n and ignore -e (always interpreting escapes)
dash (and probably old ash) supports -n but not -e ("-e" is echoed,
  escapes are always interpreted)

Really portable? printf; echo only without options and escapes.

When you mean /bin/bash, write /bin/bash, not /bin/sh.


BTW: "local" (used in our scripts) is non-POSIX too (but supported by
ksh, ash and BSD).


-- 
Jakub Bogusz    http://qboosh.pl/


More information about the pld-devel-en mailing list