Project

General

Profile

Actions

Bug #7694

closed

ksh -e continues to execute failed scripts when 'time' built-in is involved

Added by Alexander Pyhalov over 5 years ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2016-12-28
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

Reproducer:

$ cat 1.sh
#!/bin/sh
time false
echo $?
true
$ /usr/bin/ksh93 -e  1.sh && echo ok

real    0m0.00s
user    0m0.00s
sys     0m0.00s
1
ok

$ bash -e  1.sh && echo ok
# no output

If I change time to /bin/time, it behaves as expected:
$ cat 1.sh 
#!/bin/sh
/bin/time false
echo $?
true
$ /usr/bin/ksh93 -e  1.sh  && echo 1

real        0.0
user        0.0
sys         0.0
$ /usr/bin/bash -e  1.sh  && echo 1

real        0.0
user        0.0
sys         0.0

Actions #1

Updated by Andy Fiddaman 6 months ago

This has been fixed upstream in https://github.com/ksh93/ksh/pull/351

Actions #2

Updated by Andy Fiddaman 6 months ago

  • Category set to cmd - userland programs
  • Status changed from New to In Progress
  • Assignee set to Andy Fiddaman
  • Difficulty changed from Medium to Bite-size
  • Tags deleted (needs-triage)
Actions #3

Updated by Electric Monk 6 months ago

  • Gerrit CR set to 1835
Actions #4

Updated by Andy Fiddaman 6 months ago

I did some ad-hoc tests as per the original report above, and confirmed that the new regression tests fails before and passes after the change:

build:illumos:ig_7694_kshtime% export SHELL=/usr/bin/amd64/ksh

build:illumos:ig_7694_kshtime% $SHELL usr/src/contrib/ast/src/cmd/ksh93/tests/basic.sh
      basic.sh[526]: The time keyword ignores the errexit option (got $'\nreal\t0m0.00s\nuser\t0m0.00s\nsys\t0m0.00s\nFAILURE')
        basic.sh[528]: The time keyword produces output when a timed command fails and the errexit option is on (got $'\nreal\t0m0.00s\nuser\t0m0.00s\nsys\t0m0.00s\nFAILURE')

build:illumos:ig_7694_kshtime% LD_LIBRARY_PATH=usr/src/cmd/ast/libshell/amd64 $SHELL usr/src/contrib/ast/src/cmd/ksh93/tests/basic.sh
build:illumos:ig_7694_kshtime%
Actions #5

Updated by Electric Monk 6 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 6ba75e2448bdf3ae62cf3d6d13895172a2b7a249

commit  6ba75e2448bdf3ae62cf3d6d13895172a2b7a249
Author: Johnothan King <johnothanking@protonmail.com>
Date:   2021-12-04T10:50:45.000Z

    7694 ksh -e continues to execute failed scripts when 'time' built-in is involved
    Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org>
    Reviewed by: Andy Fiddaman <andy@omnios.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF