summaryrefslogtreecommitdiff
path: root/fixline1
diff options
context:
space:
mode:
Diffstat (limited to 'fixline1')
-rwxr-xr-xfixline125
1 files changed, 25 insertions, 0 deletions
diff --git a/fixline1 b/fixline1
new file mode 100755
index 0000000..113e9bb
--- /dev/null
+++ b/fixline1
@@ -0,0 +1,25 @@
+#!expect --
+# Synopsis: fixline1 newpath < input > output
+# Author: Don Libes
+
+# Description: change first line of script to reflect new binary
+# try to match any of the following first lines
+#!expect ...
+#!../expect ...
+#!expectk ...
+#!foo/bar/expectk ...
+#!/bin/sh ... (beginning of multiline #! style)
+#
+set line1 [gets stdin]
+if {"$line1" == "\#!/bin/sh"} {
+ # if multi-line hack already in place, do nothing
+ set header $line1
+} else {
+ # if single-line #!, switch to multi-line rewrite
+
+ regexp "^#!(.*/)*(.*)" $line1 X X tail
+ set header "#!/bin/sh\n"
+ append header "# \\\n"
+ append header "exec $tail "; append header {"$0" ${1+"$@"}}
+}
+puts -nonewline "$header\n[read stdin]"