scripts: fix sloppy/unpredictable cmd && this || that statements

- be a bit more POSIX to avoid any potential issues when full shell stdout/err are redirected
- actual logic chains remain unchanged
This commit is contained in:
osm0sis
2020-11-29 20:35:34 -04:00
committed by John Wu
parent a687d1347b
commit ce84f1762c
5 changed files with 52 additions and 16 deletions

View File

@ -32,7 +32,14 @@
# Pure bash dirname implementation
getdir() {
case "$1" in
*/*) dir=${1%/*}; [ -z $dir ] && echo "/" || echo $dir ;;
*/*)
dir=${1%/*}
if [ -z $dir ]; then
echo "/"
else
echo $dir
fi
;;
*) echo "." ;;
esac
}