Ticket #35304

errexit オプションの動作が POSIX 2013 に合っているか検証する

Open Date: 2015-07-05 18:07 Last Update: 2016-06-24 23:04

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
None
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

POSIX.1-2013 で errexit オプションの動作定義が変わっている。少なくとも README の記述を直す必要がある。

http://www.austingroupbugs.net/view.php?id=52 とそこで参照されている他の issues を見よ

Ticket History (3/13 Histories)

2015-07-05 18:07 Updated by: magicant
  • New Ticket "errexit オプションの動作が POSIX 2013 に合っているか検証する" created
2015-07-11 10:02 Updated by: magicant
Comment

Rationale によると "The description of the -e option is intended to match the behavior of the 1988 version of the KornShell." らしい。

2015-07-11 11:35 Updated by: magicant
Comment

複合コマンドの失敗が複合コマンド内の単純コマンドの失敗によらないというのはそもそもあまり無いので、どこまで POSIX を厳密に解釈すべきか迷うところ。

例えば以下はシェルによって動きが異なる。(今の) ksh, yash, zsh, dash は終了しないが mksh, bash は終了する。POSIX の条項を文字通り読むなら、POSIX 2008 では終了せず、POSIX 2013 では終了する。

case ${unset_variable?} in *) echo foo;; esac
2015-07-11 13:01 Updated by: magicant
  • Details Updated
2015-07-22 21:06 Updated by: magicant
Comment

Errexit の用途を考えると以下の場面では終了する方がいい気がするが、規格や他のシェルの動向を見るためしばらく置いておく。

case ${unset_variable?} in esac
for i in ${unset_variable?}; do :; done
2015-11-28 23:01 Updated by: magicant
Comment

これだと bash, dash, yash, ksh は終了せず、zsh, mksh は終了する。さすがにこれは終了した方が良かろう。

while false; do :; done <not_a_file
2016-03-20 12:17 Updated by: magicant
2016-05-26 00:31 Updated by: magicant
Comment

https://gist.github.com/magicant/aed3b01db211b8bd014e5253b3bc4c80

エッジケースで終了しないのはシェルのなすべき振る舞いとしては気に食わないので、POSIX.1-2013 の字面通りの解釈に合わせた方がいい気がしてきている。

"The description of the -e option is intended to match the behavior of the 1988 version of the KornShell." がどこまでエッジケースを考慮していたのかは不明。

2016-06-01 09:01 Updated by: None
2016-06-01 22:47 Updated by: magicant
2016-06-04 15:24 Updated by: magicant
  • Resolution Update from None to Fixed
Comment

r3628, r3629, r3630 (とその前のいくつかのコミット) で挙動を変更。POSIX.1-2013 の文字通りの動きになった。 r3631 で README を修正。

2016-06-04 15:24 Updated by: magicant
  • Ticket Close date is changed to 2016-06-04 15:24
  • Status Update from Open to Closed
2016-06-24 23:04 Updated by: magicant
Comment

r3636 で NEWS を更新

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login