From bd3a44e426a214453e2babb94b824184bc5681f7 Mon Sep 17 00:00:00 2001 From: Stanley Lieber Date: Mon, 15 Jun 2020 20:22:56 -0400 Subject: [PATCH] add bin/contrib/fix-rc-scripts (thanks, Ethan Gardner) --- bin/contrib/fix-rc-scripts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/contrib/fix-rc-scripts diff --git a/bin/contrib/fix-rc-scripts b/bin/contrib/fix-rc-scripts new file mode 100755 index 0000000..beb21c5 --- /dev/null +++ b/bin/contrib/fix-rc-scripts @@ -0,0 +1,27 @@ +#!/usr/local/plan9/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 + +# If your system lacks which (e.g. some gnu/linux) +# substitute the full path to rc in this line: +rc=/usr/local/plan9/bin/rc +firstline='#!'$"rc + +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 + } +}