Vincent Lefevre dixit:

>I hate this feature because of the ambiguity with decimal, but

Indeed. It does break traditional Korn shell scripts; I believe
this to be the second-largest mistake in recent POSIX/shell.
The ambiguity happens often enough when dealing with zero-padded
dates (e.g. in dd.MM.yyyy or yyyy-MM-dd).

I had this in mksh, but the sheer amount of changes needed to
previously unsuspecting scripts that predate this support in
POSIX led me to revert this mistake.

>mksh intends to behave like ksh93.

No. mksh only takes AT&T ksh93 behaviour as primary rule of
thumb. In fact, you will find that ksh93 behaves unlike all
other modern shells in many ways, such as scoping.

I’m hacking *on* mksh so that I can write my programs *in*
mksh, which means mksh’s focus is that of a programming
language of its own that also happens to be largely POSIX
sh compatible and leaning on AT&T ksh, but also GNU bash
and zsh.

>So, it should support octal in arithmetic expressions.

If you need features I believe ultimal failures in POSIX¹,
or other legacy behaviour, you can use the lksh binary.

① Octal in arithmetics, and using the host C “long” type for them.

On the other hand, neither lksh (since it’s intended for
legacy scripts that have not yet been ported to run with
mksh) nor mksh enable support for octal handling ootb…
see the excerpt from the manpage:

| the test built-in command. Prefixing numbers with a sole digit zero ('0')
| leads to the shell interpreting it as base-8 integer in posix mode only;
| historically, (pd)ksh has never done so either anyway, and it's unsafe to
| do that, but POSIX demands it nowadays. As a special mksh extension,

I’ll place the word “octal” in there so a manpage search finds
it more easily, in the next version.

tg@freewrt:~ $ mksh -c 'echo $((010))'
10
tg@freewrt:~ $ lksh -c 'echo $((010))'
10
tg@freewrt:~ $ mksh -o posix -c 'echo $((010))'
8
tg@freewrt:~ $ lksh -o posix -c 'echo $((010))'
8

>Shell: /bin/sh linked to /bin/dash

See /usr/share/doc/mksh/NEWS.Debian.gz for mksh (46-2), too.
Note that lksh in Debian, when called as sh, enables the POSIX
mode automatically:

tg@freewrt:~ $ ll /bin/sh
lrwxrwxrwx 1 root root 4 Aug 14 22:38 /bin/sh -> lksh*
tg@freewrt:~ $ sh -c 'echo $((010))'
8

Hence, I believe this to be ⓐ sufficiently documented, and
ⓑ not relevant for cases where you need POSIXly broken be‐
haviour (#!/bin/sh), and close this bug in Debian, and ask
you to place all follow-up discussion, should the need for
it arise, on the upstream public mailing list. Thanks!


>$ mksh -c '[ 10 -eq 010 ] && echo OK'
>OK

tg@freewrt:~ $ mksh -o posix -c '[ 10 -eq 010 ] && echo OK'
OK
tg@freewrt:~ $ lksh -o posix -c '[ 10 -eq 010 ] && echo OK'
OK



Sorry if I may be sounding rude, this is unintended,
but I caught the flu ☹

bye,
//mirabilos
-- 
“It is inappropriate to require that a time represented as
 seconds since the Epoch precisely represent the number of
 seconds between the referenced time and the Epoch.”
        -- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2

Reply via email to