resetting manifest requested domain to floor
[platform/upstream/expect.git] / fixline1
1 #!expect --
2 # Synopsis: fixline1 newpath < input > output
3 # Author: Don Libes
4
5 # Description: change first line of script to reflect new binary
6 # try to match any of the following first lines
7 #!expect ...
8 #!../expect ...
9 #!expectk ...
10 #!foo/bar/expectk ...
11 #!/bin/sh ...  (beginning of multiline #! style)
12 #
13 set line1 [gets stdin]
14 if {"$line1" == "\#!/bin/sh"} {
15     # if multi-line hack already in place, do nothing
16     set header $line1
17 } else {
18     # if single-line #!, switch to multi-line rewrite
19
20     regexp "^#!(.*/)*(.*)" $line1 X X tail
21     set header "#!/bin/sh\n"
22     append header "# \\\n"
23     append header "exec $tail "; append header {"$0" ${1+"$@"}}
24 }
25 puts -nonewline "$header\n[read stdin]"