diff options
author | Kerin Millar <kfm@plushkava.net> | 2024-08-02 23:50:54 +0100 |
---|---|---|
committer | Kerin Millar <kfm@plushkava.net> | 2024-08-03 00:08:57 +0100 |
commit | 61045c5ff6a5939f81bc64190c0d3d137f40f8c2 (patch) | |
tree | 7a73dfffc4f1bbfe706171fbc8bf0cff44f3276d | |
parent | Have hr() employ a divide-by-16 strategy (diff) | |
download | gentoo-functions-61045c5ff6a5939f81bc64190c0d3d137f40f8c2.tar.gz gentoo-functions-61045c5ff6a5939f81bc64190c0d3d137f40f8c2.tar.bz2 gentoo-functions-61045c5ff6a5939f81bc64190c0d3d137f40f8c2.zip |
Have chdir() enforce POSIX interpretation 1047
POSIX-1.2024 (Issue 8) requires for the cd builtin to raise an error
where given an empty directory operand. However, various implementations
have yet to catch up. Given that it is a sensible change, let's have the
chdir() function behave accordingly. Further, since doing so renders the
test_chdir_noop test useless, get rid of it. The purpose that the test
served is now subsumed by test_chdir.
Closes: https://bugs.gentoo.org/937157
Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r-- | functions.sh | 13 | ||||
-rwxr-xr-x | test-functions | 17 |
2 files changed, 11 insertions, 19 deletions
diff --git a/functions.sh b/functions.sh index 9b6220b..7dd4d8f 100644 --- a/functions.sh +++ b/functions.sh @@ -42,13 +42,20 @@ # chdir() { + if [ "$#" -eq 1 ]; then + case $1 in + '') + _warn_for_args chdir "$1" + return 1 + ;; + -) + set -- ./- + esac + fi if [ "${BASH}" ]; then # shellcheck disable=3044 shopt -u cdable_vars fi - if [ "$1" = - ]; then - set -- ./- - fi # shellcheck disable=1007,2164 CDPATH= cd -- "$@" } diff --git a/test-functions b/test-functions index 2ad76e8..db89e73 100755 --- a/test-functions +++ b/test-functions @@ -49,6 +49,7 @@ test_local() { test_chdir() { set -- \ + ge 1 '' \ ge 1 grandchild \ ge 1 var \ eq 0 -L \ @@ -77,21 +78,6 @@ test_chdir() { iterate_tests 3 "$@" } -test_chdir_noop() { - set -- \ - eq 0 '' - - callback() { - shift - test_description="chdir $(quote_args "$@")" - chdir "$@" \ - && test "$PWD" = "$OLDPWD" \ - || { cd - >/dev/null; false; } - } - - iterate_tests 3 "$@" -} - test_die() { set -- \ eq 1 0 \ @@ -891,7 +877,6 @@ elif ! GENFUN_MODULES="portage rc" . ./functions.sh; then else assign_tmpdir test_chdir || rc=1 - test_chdir_noop || rc=1 ( test_ebegin ) || rc=1; testnum=$((testnum + 1)) test_is_older_than || rc=1 test_get_bootparam || rc=1 |