shithub: riscv

Download patch

ref: 53f2b41ec64895a1d8bcebeeb7824c59e854eb13
parent: db6883559fb0f243f94d0a2dfab75f866e651652
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Aug 5 18:46:08 EDT 2022

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.

--- 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 @@
 		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
 }