summaryrefslogtreecommitdiff
path: root/fixline1
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-04 17:21:04 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-04 17:21:04 -0800
commite0b431a48cc3ac5d3ec32f06eddd9708ad655fa2 (patch)
treece4c73521220fbb751c2be6a42e85ff6a6cbff97 /fixline1
downloadexpect-e0b431a48cc3ac5d3ec32f06eddd9708ad655fa2.tar.gz
expect-e0b431a48cc3ac5d3ec32f06eddd9708ad655fa2.tar.bz2
expect-e0b431a48cc3ac5d3ec32f06eddd9708ad655fa2.zip
Imported Upstream version 5.45upstream/5.45
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]"