33 lines
689 B
Text
33 lines
689 B
Text
|
#!/usr/bin/env execlineb
|
||
|
|
||
|
elgetopt d
|
||
|
elgetpositionals
|
||
|
importas -D "" dironly ELGETOPT_d
|
||
|
|
||
|
if -nt { test $# -eq 0 }
|
||
|
|
||
|
define FOUND 69
|
||
|
foreground {
|
||
|
# look for each file (in cwd)
|
||
|
forx -E -x$FOUND pat { $@ }
|
||
|
# if file exists, exit with $FOUND, which breaks the loop
|
||
|
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 :
|