]> arthur.barton.de Git - ax-zsh.git/commitdiff
std_functions: Further tweak untake()
authorAlexander Barton <alex@barton.de>
Sat, 20 Jan 2024 22:38:47 +0000 (23:38 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 20 Jan 2024 22:39:49 +0000 (23:39 +0100)
default_plugins/std_functions/std_functions.zshrc

index 69d65113ffa2baff69339ebb65560cd75c86ffe5..47ca9123062a867099222e7139de76db172cebd2 100644 (file)
@@ -33,12 +33,16 @@ function take() {
 }
 
 function untake() {
-       if [[ "${PWD%tmp.*}" = "${TMPDIR}" ]]; then
-               pwd
+       pwd="${PWD}/"
+       subdir="${pwd##$TMPDIR}"
+       if [[ "${PWD%tmp.*}" = "${TMPDIR}" && -n "$subdir" ]]; then
+               tmp_d="${TMPDIR}${subdir%%/*}"
+               echo "$tmp_d"
                cd
-               rm -fri "$@" "${OLDPWD}"
+               rm -fr "$@" "${tmp_d}"
        else
                echo 'Sorry, not a temporarily taken directory!' >&2
+               return 1
        fi
 }