2 # Synopsis: fixline1 newpath < input > output
5 # Description: change first line of script to reflect new binary
6 # try to match any of the following first lines
11 #!/bin/sh ... (beginning of multiline #! style)
13 set line1 [gets stdin]
14 if {"$line1" == "\#!/bin/sh"} {
15 # if multi-line hack already in place, do nothing
18 # if single-line #!, switch to multi-line rewrite
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+"$@"}}
25 puts -nonewline "$header\n[read stdin]"