Improved some more bash script variable definitions
This commit is contained in:
@@ -132,15 +132,15 @@ KUBE_NONSERVER_GROUP_VERSIONS="
|
||||
function kube::readlinkdashf {
|
||||
# run in a subshell for simpler 'cd'
|
||||
(
|
||||
if [[ -d "$1" ]]; then # This also catch symlinks to dirs.
|
||||
cd "$1"
|
||||
if [[ -d "${1}" ]]; then # This also catch symlinks to dirs.
|
||||
cd "${1}"
|
||||
pwd -P
|
||||
else
|
||||
cd "$(dirname "$1")"
|
||||
cd "$(dirname "${1}")"
|
||||
local f
|
||||
f=$(basename "$1")
|
||||
if [[ -L "$f" ]]; then
|
||||
readlink "$f"
|
||||
f=$(basename "${1}")
|
||||
if [[ -L "${f}" ]]; then
|
||||
readlink "${f}"
|
||||
else
|
||||
echo "$(pwd -P)/${f}"
|
||||
fi
|
||||
@@ -176,9 +176,9 @@ function kube::readlinkdashf {
|
||||
# testone $T/linkdir/linkfile
|
||||
# testone $T/linkdir/linkdir
|
||||
kube::realpath() {
|
||||
if [[ ! -e "$1" ]]; then
|
||||
echo "$1: No such file or directory" >&2
|
||||
if [[ ! -e "${1}" ]]; then
|
||||
echo "${1}: No such file or directory" >&2
|
||||
return 1
|
||||
fi
|
||||
kube::readlinkdashf "$1"
|
||||
kube::readlinkdashf "${1}"
|
||||
}
|
||||
|
Reference in New Issue
Block a user