summaryrefslogtreecommitdiff
path: root/rc/bin/src
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-08-05 22:46:08 +0000
committerOri Bernstein <ori@eigenstate.org>2022-08-05 22:46:08 +0000
commit53f2b41ec64895a1d8bcebeeb7824c59e854eb13 (patch)
tree52d7b1a1dced8535a9f6ba91b3009b5831f6e4b5 /rc/bin/src
parentdb6883559fb0f243f94d0a2dfab75f866e651652 (diff)
src: search for binaries in path, not random places
it's confusing and overly cute when 'src notinpath' works. only accept paths that you can execute.
Diffstat (limited to 'rc/bin/src')
-rwxr-xr-xrc/bin/src20
1 files changed, 11 insertions, 9 deletions
diff --git a/rc/bin/src b/rc/bin/src
index 1855a6044..175800bfb 100755
--- a/rc/bin/src
+++ b/rc/bin/src
@@ -1,7 +1,6 @@
#!/bin/rc
rfork e
-path=(/bin/)
sym = 'threadmain?z
main?z'
@@ -46,12 +45,15 @@ while(~ $1 -*)
usage
}
-if(~ $#* 0) usage
-
-for(i){
- if(test -f $i) go $i
- if not if(test -f /bin/$i) go /bin/$i
- if not if(test -f /bin/*/$i) go /bin/*/$i
- if not if(test -f /bin/*/*/$i) go /bin/*/*/$i
- if not echo 'src: can''t find '$i
+if(~ $#* 0)
+ usage
+for(i in $*){
+ if(~ $i /*){
+ test -f $i && go $i && exit
+ }
+ if not{
+ for(f in $path^/^$i)
+ test -f $f && go $f && exit
+ }
+ echo 'src: can''t find '$i
}