2022-05-20 05:54:47 -04:00
|
|
|
#!/usr/bin/env execlineb
|
|
|
|
|
|
|
|
elgetopt d
|
|
|
|
elgetpositionals
|
|
|
|
importas -D "" dironly ELGETOPT_d
|
|
|
|
|
|
|
|
if -nt { test $# -eq 0 }
|
|
|
|
|
|
|
|
define FOUND 69
|
|
|
|
foreground {
|
2022-05-20 06:44:13 -04:00
|
|
|
# look for each pattern (in cwd)
|
2022-05-20 05:54:47 -04:00
|
|
|
forx -E -x$FOUND pat { $@ }
|
2022-05-20 06:44:13 -04:00
|
|
|
# if a file exists, exit with $FOUND, which breaks the loop
|
2022-05-20 05:54:47 -04:00
|
|
|
elglob -0 files $pat
|
|
|
|
forx -E -x$FOUND file { $files }
|
|
|
|
ifthenelse { test -n $dironly } { pwd } { readlink -f $file }
|
|
|
|
exit $FOUND
|
|
|
|
}
|
|
|
|
importas result ?
|
|
|
|
|
|
|
|
# if the loop exited with $FOUND then we're done
|
|
|
|
if -nt { test $result -eq $FOUND }
|
|
|
|
# if we're at / give up
|
|
|
|
if -n -x1 {
|
|
|
|
getcwd -E cwd
|
|
|
|
test $cwd = /
|
|
|
|
}
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
ifelse { test -n $dironly } { find-parent -d $@ } find-parent $@
|
|
|
|
|
|
|
|
# vim: set ft=execline :
|