Commit b8c923db authored by Vitaly Lipatov's avatar Vitaly Lipatov

update which replacement code

parent a57a12b0
......@@ -8,7 +8,7 @@ DESCRIPTION="AIMP (Wine based audio player) from the official site"
pkgtype="$(epm print info -p)"
if ! which wine ; then
if ! is_command wine ; then
epm play wine || fatal
fi
......
......@@ -6,6 +6,33 @@ fatal()
exit 1
}
# print a path to the command if exists in $PATH
if a= which which 2>/dev/null >/dev/null ; then
# the best case if we have which command (other ways needs checking)
# TODO: don't use which at all, it is binary, not builtin shell command
print_command_path()
{
a= which -- "$1" 2>/dev/null
}
elif a= type -a type 2>/dev/null >/dev/null ; then
print_command_path()
{
a= type -fpP -- "$1" 2>/dev/null
}
else
print_command_path()
{
a= type "$1" 2>/dev/null | sed -e 's|.* /|/|'
}
fi
# check if <arg> is a real command
is_command()
{
print_command_path "$1" >/dev/null
}
eget()
{
epm tool eget "$@"
......
......@@ -8,22 +8,22 @@ fatal()
# compatibility layer
# print a path to the command if exists in $PATH
if which which 2>/dev/null >/dev/null ; then
if a= which which 2>/dev/null >/dev/null ; then
# the best case if we have which command (other ways needs checking)
# TODO: don't use which at all, it is binary, not builtin shell command
print_command_path()
{
which -- "$1" 2>/dev/null
a= which -- "$1" 2>/dev/null
}
elif type -a type 2>/dev/null >/dev/null ; then
elif a= type -a type 2>/dev/null >/dev/null ; then
print_command_path()
{
type -fpP -- "$1" 2>/dev/null
a= type -fpP -- "$1" 2>/dev/null
}
else
print_command_path()
{
type "$1" 2>/dev/null | sed -e 's|.* /|/|'
a= type "$1" 2>/dev/null | sed -e 's|.* /|/|'
}
fi
......@@ -33,6 +33,7 @@ is_command()
print_command_path "$1" >/dev/null
}
# compatibility layer
# add realpath if missed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment