From 0e854b1a7d278a386553a6a4feb34a9578d5aa74 Mon Sep 17 00:00:00 2001 From: Maarten Bezemer Date: Wed, 23 Jul 2014 23:11:25 +0200 Subject: [linux] Make checking for command existence more consistent and POSIX compatible --- tools/Linux/xbmc.sh.in | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tools/Linux') 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 -- cgit v1.2.3