From e2c442a7bae857d209cee71b3544726c155d47c5 Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Sat, 1 Sep 2001 19:27:42 +0200
Subject: [PATCH] Pass on the argument value of the magic --gdb arg to gdb.
 Useful to start pike in gdb and run it right away with pike --gdb=r ...

Rev: bin/pike.in:1.9
---
 bin/pike.in | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/bin/pike.in b/bin/pike.in
index 51924ce635..90d45a9a54 100644
--- a/bin/pike.in
+++ b/bin/pike.in
@@ -1,5 +1,10 @@
 #!/bin/sh
 # Runs Pike directly from the build directory.
+#
+# If the first argument is --gdb, Pike will be loaded inside a gdb
+# session with the remaining arguments. If --gdb has a value, e.g.
+# --gdb=run, the value will be passed as a command to be executed
+# initially by gdb.
 
 BUILDDIR="BUILDDIR"
 
@@ -8,7 +13,8 @@ if test $BUILDDIR = BUILDDIR; then
   exit 1
 fi
 
-if test x"$1" = x--gdb; then
+if expr x"$1" : 'x--gdb' >/dev/null; then
+  gdbarg=`expr "$1" : '--gdb=\(.*\)'`
   shift
   args="set args '-m$BUILDDIR/master.pike'"
   for arg do
@@ -22,6 +28,9 @@ EOF`
     cp .gdbinit.orig .gdbinit
   fi
   echo $args >> .gdbinit
+  if test x"$gdbarg" != x; then
+    echo "$gdbarg" >> .gdbinit
+  fi
   gdb "$BUILDDIR/pike"
   rm .gdbinit
   test -f .gdbinit.orig && mv .gdbinit.orig .gdbinit
-- 
GitLab