]> piware.de Git - bin.git/commitdiff
add shellpresent
authormartin@piware.de <>
Sat, 4 Apr 2009 14:47:59 +0000 (07:47 -0700)
committermartin@piware.de <>
Sat, 4 Apr 2009 14:47:59 +0000 (07:47 -0700)
shellpresent [new file with mode: 0755]

diff --git a/shellpresent b/shellpresent
new file mode 100755 (executable)
index 0000000..8747d88
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Present a list of shell commands by single-stepping and echoing commands.
+# Note that this only works well for self-contained single lines, no multi-line
+# loops etc.
+#
+# (c) 2009 Martin Pitt <martin@piware.de>
+# License: Public Domain
+
+[ -e "$1" ] || {
+    echo "Usage: $0 <shell script>" >&2
+    exit 1
+}
+
+clear
+
+while read line; do
+    # paragraph clears screen
+    if [ -z "$line" ]; then
+       clear
+       continue
+    fi
+
+    # comment
+    if [ "${line:0:1}" = "#" ]; then
+       if [ -n "${line:1}" ]; then
+           echo -e "\e[32m$line\e[30m"
+       fi
+       continue
+    fi
+
+    # execute command
+    echo -en "\e[31m\$\e[30m $line"
+    read < /dev/tty
+    eval "$line"
+    read < /dev/tty
+done < "$1"