diff --git a/bin/pike.in b/bin/pike.in
index 51924ce635f82929de8977e112c3ae8211029d52..90d45a9a547a7b8ca208e90f6f873acf5b44078f 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