fc -e の終了状態が無効です。

fc -e の終了状態が無効です。

Bashの組み込みコマンドを使用して前のコマンドを編集して呼び出そうとしましたがfc、どういうわけか終了ステータスは機能していないにもかかわらず、編集が正常に失敗したことを示します。デモ:

$ uname
Linux
$ fc -e vi
:q
uname
Linux
$ echo $?
1
$ # Would have expected 0 here: successful re-invocation

からman bash

   fc [-e ename] [-lnr] [first] [last]
   fc -s [pat=rep] [cmd]
          [...]
          If  the  first  form  is  used,  the return value is 0 unless an
          invalid option is encountered or first or last  specify  history
          lines  out  of  range.  If the -e option is supplied, the return
          value is the value of the last command executed or failure if an
          error occurs with the temporary file of commands.  [...]

もっと詳しく見ると、次のようになります。

$ uname
Linux
$ fc -e true -1  # No-op editor, should succeed.
uname
Linux
$ echo $?
1
$ # Why does this recall, but fail?
$ fc -e false -1 # Editor fails, no command invocation and failure, fine.
$ echo $?
1
$ fc -e rm -1    # This removes the temporary file, should fail, too!?
$ echo $?
0
$ # But actually this is the only branch that causes fc to succeed?!

私にfc終了状態はその逆ではありません。

私はUbuntu 14.04.4 LTSのBash 4.3.11(1)リリース、Ubuntu 16.04 LTSのBash 4.3.42(1)リリース、およびCentOS 7のBash 4.2.46(1)リリースでこれを見ました。この点。これはバグですか?

ベストアンサー1

はい、これは間違いです。この問題は2015年11月に報告され修正されました。http://lists.gnu.org/archive/html/bug-bash/2015-11/msg00107.html

私はGitリポジトリでのみ修正を確認できませんでしたmaster。現時点ではdevel修正がそこにあるようです。 Bashバージョンがリリースされたら、この回答を更新します。

おすすめ記事