Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.shell > #22496

Re: [ANN] KornShell 93u+m 1.0.0-beta.2

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Martijn Dekker <martijn@inlv.demon.nl>
Newsgroups comp.unix.shell
Subject Re: [ANN] KornShell 93u+m 1.0.0-beta.2
Date Fri, 17 Dec 2021 11:18:26 +0100
Lines 49
Message-ID <j236fkFldviU1@mid.individual.net> (permalink)
References <j22f1cFh5m2U1@mid.individual.net> <sphijs$ejq$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net 70/e0QVIdYBlQoSgyPpsSwkA8mcuJahn3QuKjboWQdl5bO/Ic=
Cancel-Lock sha1:xo2Nj6EBjG++uLMsm+D5fjrJ4NY=
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.4.0
Content-Language en-CA
In-Reply-To <sphijs$ejq$1@dont-email.me>
Xref csiph.com comp.unix.shell:22496

Show key headers only | View raw


Op 17-12-21 om 09:43 schreef Janis Papanagnou:
> I'll have a look into the details soon, but this one irritated me;
> but maybe I just misunderstood it:
> 
>> - The 'return' command, when used to return from a function, can now
>>    return any status value in the 32-bit signed integer range, like on
>>    zsh. However, due to a traditional Unix kernel limitation, $? is
>>    still trimmed to its least significant 8 bits whenever leaving a
>>    (sub)shell environment.
> 
> If in Kornshell I terminate a process with a signal I get a number
> returned that is beyond the 8 bit range; e.g. a kill (with SIGTERM)
> results in $? evaluating to 271.

Yes, that has not changed.

If a child process of ksh's is terminated by a signal, ksh doesn't 
inherit the exit status via the kernel as that process didn't exit 
normally. Instead, ksh detects that the process was terminated by a 
signal (see 'man 2 wait' for how that works) and sets $? to the signal 
number with the 9th bit set in the current process -- which is not 
subject to the kernel's 8-bit exit status limitation as that all happens 
in the parent process.

What the announcement item above means instead is this:

$ myfunc() { return 12345; }
$ myfunc; echo $?
12345
$ (myfunc); echo $?
57
$ ksh -c 'myfunc() { return 12345; }; myfunc'; echo $?
57

i.e., the exit status of a subshell or child shell that invokes 
'myfunc', and does nothing to overwrite $? before exiting, is the least 
significant 8 bits of 12345, i.e., 12345 % 0xFF == 210.

For consistency's sake, ksh 93u+m enforces this for virtual 
(non-forking) subshells as well, because a script should never be able 
to notice a difference between a virtual subshell and a subshell that 
forked a separate process due to executing something like 'ulimit'.

-- 
||    modernish -- harness the shell
||    https://github.com/modernish/modernish
||
||    KornShell lives!
||    https://github.com/ksh93/ksh

Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[ANN] KornShell 93u+m 1.0.0-beta.2 Martijn Dekker <martijn@inlv.demon.nl> - 2021-12-17 04:38 +0100
  Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Janis Papanagnou <janis_papanagnou@hotmail.com> - 2021-12-17 09:43 +0100
    Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Martijn Dekker <martijn@inlv.demon.nl> - 2021-12-17 11:18 +0100
      Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Spiros Bousbouras <spibou@gmail.com> - 2021-12-17 12:50 +0000
        Arithmetic trivia (Was: [ANN] KornShell 93u+m 1.0.0-beta.2) gazelle@shell.xmission.com (Kenny McCormack) - 2021-12-17 13:10 +0000
          Re: Arithmetic trivia (Was: [ANN] KornShell 93u+m 1.0.0-beta.2) Janis Papanagnou <janis_papanagnou@hotmail.com> - 2021-12-17 21:39 +0100
        Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Martijn Dekker <martijn@inlv.demon.nl> - 2021-12-17 19:58 +0000
  Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Janis Papanagnou <janis_papanagnou@hotmail.com> - 2021-12-18 15:07 +0100
    Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Martijn Dekker <martijn@inlv.demon.nl> - 2021-12-19 21:00 +0000
      Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Martijn Dekker <martijn@inlv.demon.nl> - 2021-12-21 19:12 +0000
      Re: [ANN] KornShell 93u+m 1.0.0-beta.2 Janis Papanagnou <janis_papanagnou@hotmail.com> - 2021-12-24 14:46 +0100

csiph-web