commit: 61045c5ff6a5939f81bc64190c0d3d137f40f8c2 Author: Kerin Millar <kfm <AT> plushkava <DOT> net> AuthorDate: Fri Aug 2 22:50:54 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Fri Aug 2 23:08:57 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=61045c5f
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 <AT> plushkava.net> functions.sh | 13 ++++++++++--- 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
