diff options
author | Maarten Bezemer <maarten.bezemer@gmail.com> | 2014-07-23 23:11:25 +0200 |
---|---|---|
committer | Maarten Bezemer <maarten.bezemer@gmail.com> | 2014-07-23 23:11:25 +0200 |
commit | 0e854b1a7d278a386553a6a4feb34a9578d5aa74 (patch) | |
tree | 21ea80a49b23fbbe6d0df788fa39bd0520a19d33 /tools/Linux | |
parent | 7cb2f01504fa8d0e5f695590db69500e3812210e (diff) |
[linux] Make checking for command existence more consistent and POSIX compatible
Diffstat (limited to 'tools/Linux')
-rw-r--r-- | tools/Linux/xbmc.sh.in | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/Linux/xbmc.sh.in b/tools/Linux/xbmc.sh.in index db99670547..14a082b253 100644 --- a/tools/Linux/xbmc.sh.in +++ b/tools/Linux/xbmc.sh.in @@ -39,6 +39,11 @@ do esac done +command_exists() +{ + command -v $1 >/dev/null 2>&1 +} + single_stacktrace() { # core filename is either "core.$PID" or "core" @@ -68,7 +73,7 @@ print_crash_report() if [ -f /etc/os-release ]; then . /etc/os-release echo $NAME $VERSION >> $FILE - elif which lsb_release > /dev/null; then + elif command_exists lsb_release; then echo >> $FILE lsb_release -a 2> /dev/null | sed -e 's/^/ /' >> $FILE else @@ -77,8 +82,8 @@ print_crash_report() echo "############## END SYSTEM INFO ##############" >> $FILE echo >> $FILE echo "############### STACK TRACE #################" >> $FILE - if which gdb >/dev/null 2>&1; then - if which systemd-coredumpctl &> /dev/null; then + if command_exists gdb; then + if command_exists systemd-coredumpctl; then systemd-coredumpctl dump -o core xbmc.bin &> /dev/null fi single_stacktrace "$PWD" 1 @@ -120,7 +125,7 @@ if [ $RET -ne 0 ]; then exit $RET fi -if which gdb >/dev/null 2>&1; then +if command_exists gdb; then # Output warning in case ulimit is unsupported by shell eval ulimit -c unlimited if [ ! $? = "0" ]; then |