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 /functions.sh | |
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>
Diffstat (limited to 'functions.sh')
-rw-r--r-- | functions.sh | 13 |
1 files changed, 10 insertions, 3 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 -- "$@" } |