improve next-in-path handling, fix line endings
This commit is contained in:
parent
f546b49599
commit
31a59f0207
14 changed files with 62 additions and 48 deletions
|
|
@ -2,12 +2,19 @@
|
|||
# Usage: next-in-path <program name> <current $0>
|
||||
typeset -U path
|
||||
next-in-path() {
|
||||
entries=( $(which -a $1) )
|
||||
index=${entries[(ie)$2]}
|
||||
local entries=( $(which -a $1) )
|
||||
local index=${entries[(ie)$2]}
|
||||
local result
|
||||
if [[ $index -le ${#entries} ]]; then
|
||||
# found $0, use next entry
|
||||
echo $entries[$((index + 1))]
|
||||
result=$entries[$((index + 1))]
|
||||
else
|
||||
echo $entries[1]
|
||||
result=$entries[1]
|
||||
fi
|
||||
|
||||
if [[ -n $result ]]; then
|
||||
echo $result
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue