Merge pull request #215 from ruslan-sem/patch-1

lib/functions: Update "alias_value"
This commit is contained in:
Koichi Murase 2022-10-07 19:27:04 +09:00 committed by GitHub
commit 6cf681027f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,10 +49,16 @@ function open_command() {
# 0 if the alias was found,
# 1 if it does not exist
#
function alias_value() {
alias "$1" | sed "s/^$1='\(.*\)'$/\1/"
test $(alias "$1")
}
if ((_omb_bash_version >= 40000)); then
function alias_value() {
[[ ${BASH_ALIASES[$1]+set} ]] && echo "${BASH_ALIASES[$1]}"
}
else
function alias_value() {
local value=
value=$(alias "$1" 2>/dev/null) && eval "value=${value#*=}" && echo "$value"
}
fi
#
# Try to get the value of an alias,