2021-11-15 11:52:52 +00:00
|
|
|
# find next entry in PATH for wrapper scripts
|
|
|
|
# Usage: next-in-path <program name> <current $0>
|
2023-02-13 17:08:13 +00:00
|
|
|
typeset -U path
|
2021-11-15 11:52:52 +00:00
|
|
|
next-in-path() {
|
|
|
|
entries=( $(which -a $1) )
|
|
|
|
index=${entries[(ie)$2]}
|
|
|
|
if [[ $index -le ${#entries} ]]; then
|
|
|
|
# found $0, use next entry
|
|
|
|
echo $entries[$((index + 1))]
|
|
|
|
else
|
|
|
|
echo $entries[1]
|
|
|
|
fi
|
|
|
|
}
|