From b663cee8d182f2eb9ffeb0837c4e2eb68a674483 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Wed, 1 Sep 2021 14:17:56 +0900 Subject: [PATCH] util (bleopt,bind): fix an error message and the error exit status --- memo/ChangeLog.md | 1 + note.txt | 10 ++++++---- src/decode.sh | 10 +++++----- src/util.sh | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index 8e1d73b7..0bd4ea66 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -51,6 +51,7 @@ - util (`blehook`): show explicitly specified internal hooks `#D1594` f4312df - util (`bleopt`): do no select obsoleted options by wildcards `#D1595` f4312df - util (`bleopt`): fix error messages for unknown options `#D1610` 66df3e2 + - util (`bleopt`, `bind`): fix error message and exit status, respectively `#D1640` 0000000 - progcomp: support quoted commands and better `progcomp_alias` `#D1581` `#D1583` dbe87c3 - progcomp: fix a bug that command names may stray into completer function names `#D1611` 1f2d45f - syntax: highlight quotes of the `\?` form `#D1584` 5076a03 diff --git a/note.txt b/note.txt index 46789b97..191bc650 100644 --- a/note.txt +++ b/note.txt @@ -1616,10 +1616,6 @@ bash_tips ./ble.pp:145: { ((${#BASH_SOURCE[@]})) && [[ ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} == *bashrc ]]; } || ./src/decode.sh:3632: [[ ${keys[*]} != "$bind_keys" ]] && -2021-07-20 - - * bind --help の exit status が 1 になっている - 2021-07-14 * bash-it によるプロンプト設定が prompt attach で反映されない。 @@ -4991,6 +4987,12 @@ bash_tips 2021-09-01 + * util (bleopt, bind): fix interfaces [#D1640] + + * bleopt の unknown option のエラーメッセージでオプション名が '-c' 固定になっている。 + + * 2021-07-20 bind --help の exit status が 1 になっている。2 であるべき。 + * complete: 古い bash における -D, -I の対応 [#D1639] どうやら -D, -I はそれぞれ内部的には _DefaultCmD_, _InitialWorD_ という名 diff --git a/src/decode.sh b/src/decode.sh index 03459a3f..940ee083 100644 --- a/src/decode.sh +++ b/src/decode.sh @@ -3871,13 +3871,13 @@ function ble/builtin/bind { nocasematch=1 ble/decode/initialize - local flags= + local flags= ext=0 ble/builtin/bind/.process "$@" if [[ $_ble_decode_bind_state == none ]]; then - builtin bind "$@" - else - [[ $flags != *[eh]* ]] - fi; local ext=$? + builtin bind "$@"; ext=$? + elif [[ $flags == *[eh]* ]]; then + ext=2 + fi [[ $nocasematch ]] && shopt -s nocasematch diff --git a/src/util.sh b/src/util.sh index 14174445..3e7799ef 100644 --- a/src/util.sh +++ b/src/util.sh @@ -73,7 +73,7 @@ function bleopt/.read-arguments { (u) bleopt/.read-arguments/process-option changed ;; (I) bleopt/.read-arguments/process-option initialize ;; (*) - ble/util/print "bleopt: unrecognized option '-c'." >&2 + ble/util/print "bleopt: unrecognized option '-$c'." >&2 flags=E$flags ;; esac done ;;