drop `dirname` in favor of native Bash strings (2 of 2)

Convert `var=${dirname $filename)` to `var="${filename%/*}`, everywhere except *plugin/z_autoenv*.
pull/1914/head
John D Pell 2021-09-05 16:15:11 -07:00
parent 550b8e33e7
commit 30a9c06f8b
5 changed files with 6 additions and 6 deletions

View File

@ -30,7 +30,7 @@ __gradle-set-project-root-dir() {
project_root_dir=$dir
return 0
fi
dir="$(dirname "$dir")"
dir="${dir%/*}"
done
return 1
}

View File

@ -35,8 +35,8 @@ End-Of-Usage
continue
fi
local -r filename=$(basename -- $1)
local -r filedirname=$(dirname -- $1)
local -r filename=${1##*/}
local -r filedirname=${1%/*}
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename)
if [ "$filename" = "$targetdirname" ]; then
# archive type either not supported or it doesn't need dir creation

View File

@ -12,7 +12,7 @@ function gw() {
result="${curr_path}/${file}"
break
else
curr_path=$(dirname "${curr_path}")
curr_path="${curr_path%/*}"
fi
done

View File

@ -21,7 +21,7 @@ function pyedit() {
return -1
elif [[ $xpyc == *__init__.py* ]]; then
xpydir=`dirname $xpyc`;
xpydir=${xpyc%/*};
echo "$EDITOR $xpydir";
$EDITOR "$xpydir";
else

View File

@ -352,7 +352,7 @@ function get_hg_root {
return
fi
CURRENT_DIR=$(dirname "$CURRENT_DIR")
CURRENT_DIR="${CURRENT_DIR%/*}"
done
}