]> git.sthu.org Git - vimconf.git/commitdiff
gdb: Check if gdb-dashboard is installed
authorStefan Huber <shuber@sthu.org>
Sat, 30 Jan 2021 18:48:42 +0000 (19:48 +0100)
committerStefan Huber <shuber@sthu.org>
Sat, 30 Jan 2021 18:48:42 +0000 (19:48 +0100)
gdb.sh

diff --git a/gdb.sh b/gdb.sh
index a1bbc344244f822c4e63e26c464ca615692ddb74..25ba3524c04b37adefe63b15b2f3bf50cbea3c7f 100755 (executable)
--- a/gdb.sh
+++ b/gdb.sh
@@ -1,9 +1,25 @@
 #!/bin/sh
 
+set -eu
+
+GDBBIN="gdb"
 GDBARGS=""
+WITH_DASHBOARD=0
+
+# If gdb-dashboard is installed, use it
+if command -v gdb-dashboard &> /dev/null; then
+    GDBBIN="gdb-dashboard"
+    WITH_DASHBOARD=1
+fi
 
+# Check if gdbinit ships gdb-dashboard
 if [ -e ~/.gdbinit ] && grep -q dashboard ~/.gdbinit; then
+    WITH_DASHBOARD=1
+fi
+
+# If we use dashboard then pass corresponding gdbinit file
+if [ "${WITH_DASHBOARD}" = "1" ]; then
     GDBARGS="${GDBARGS} -x ~/.vim/gdbinit-dashboard"
 fi
 
-exec gdb ${GDBARGS} "$@"
+exec ${GDBBIN} ${GDBARGS} "$@"