Commit d1597a87 authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info: simplify print_command_path with is_bash + command -v

parent a9cd7688
......@@ -26,24 +26,22 @@ has()
grep "$*" "$DISTROFILE" >/dev/null 2>&1
}
# copied from epm-sh-functions
# 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()
# detect bash
is_bash()
{
a='' which -- "$1" 2>/dev/null
[ -n "$BASH_VERSION" ]
}
elif a='' type -a type 2>/dev/null >/dev/null ; then
# print a path to the command if exists in $PATH
if is_bash ; then
print_command_path()
{
a='' type -fpP -- "$1" 2>/dev/null
type -fpP -- "$1" 2>/dev/null
}
else
print_command_path()
{
a='' type "$1" 2>/dev/null | sed -e 's|.* /|/|'
command -v "$1" 2>/dev/null
}
fi
......
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