#!/bin/rc # Fix rc shell scripts to find rc without launching env every time. # Invoke with rc and plan9 versions of grep and ed in $PATH # new version: fixes awk scripts too rc=`{whatis rc} awk=`{whatis awk} firstline='#!'$"rc firstline_awk='#!'$"awk' -f' if(~ $#* 0) files = * if not files = $* myname = `{basename $0} for(file in $files) { if(test -d $file) $0 $file/* if not if(~ $file *$myname) {} if not if(sed 1q $file | grep '^#!/.*[/ ]rc$' > /dev/null) { { echo 1c echo $firstline echo . echo wq } | ed $file > /dev/null } if not if(sed 1q $file | grep '^#!/.*[/ ]awk[ ]+-f$' > /dev/null) { { echo 1c echo $firstline_awk echo . echo wq } | ed $file > /dev/null } }