add rc scripts ", "" and g from rsc
This commit is contained in:
parent
51b39ae43c
commit
67fe83b40f
3 changed files with 61 additions and 0 deletions
25
rc/bin/"
Executable file
25
rc/bin/"
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/rc
|
||||
|
||||
rfork en
|
||||
|
||||
if(test -r /mnt/acme/acme/body)
|
||||
bind /mnt/acme/acme/body /dev/text
|
||||
|
||||
PROMPT='[^ ]*%[ ]+'
|
||||
|
||||
fn cmds {
|
||||
grep '^'$PROMPT'[^"]' /dev/text | sed 's/^/ /'
|
||||
}
|
||||
|
||||
switch($#*) {
|
||||
case 0
|
||||
cmds | tail -1
|
||||
case *
|
||||
cmds | grep '^ '$PROMPT^$"* | {echo; cat} |
|
||||
pr -t -n | sort -nr | sort -u +1 | sort -n |
|
||||
sed 's/^ *[0-9]+ //' | grep .
|
||||
}
|
||||
|
||||
# the silly {echo; cat} gets around pr printing "empty file" when
|
||||
# presented with no input.
|
||||
|
13
rc/bin/""
Executable file
13
rc/bin/""
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/rc
|
||||
|
||||
PROMPT='[^ ]*%+[ ]+'
|
||||
|
||||
_x = `{" $* | tail -1}
|
||||
if(~ $#_x 0) {
|
||||
echo no such command found
|
||||
exit notfound
|
||||
}
|
||||
|
||||
echo ' ' $_x
|
||||
_x=`{ echo -n 'eval '; echo $_x | sed 's/^'$PROMPT'//'}
|
||||
rc -c $"_x
|
23
rc/bin/g
Executable file
23
rc/bin/g
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/rc
|
||||
|
||||
flags=()
|
||||
while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
|
||||
flags=($flags $1);
|
||||
shift
|
||||
}
|
||||
if(~ $1 --)
|
||||
shift
|
||||
|
||||
switch($#*){
|
||||
case 0
|
||||
echo 'usage: g [flags] pattern [files]' >[1=2]
|
||||
exit usage
|
||||
case 1
|
||||
pattern=$1
|
||||
files=(`{ls *.[bcChm] *.cc *.py *.tex *.ms *.java >[2]/dev/null})
|
||||
case *
|
||||
pattern=$1
|
||||
shift
|
||||
files=($*)
|
||||
}
|
||||
grep -n $flags -- $pattern $files /dev/null
|
Loading…
Reference in a new issue