Skip to content

Commit

Permalink
adding rfind
Browse files Browse the repository at this point in the history
  • Loading branch information
git2samus committed Aug 22, 2011
1 parent 62c21ae commit 1e0ca2a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .functionrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ nl_join() {
list_join $'\n' "$@"
}; export -f nl_join

rfind() {
# reverse find
local target="$1" cwd="$PWD"

[[ "$target" ]] || { echo "ERROR: missing target" >&2; return 1; }

while [[ "$cwd" ]]; do
if [[ -e "$cwd"/"$target" ]]; then
echo "$cwd"/"$target"
return 0
fi
cwd="${cwd%/*}"
done
return 1
}; export -f rfind

filter_uniq() {
awk '!a[$0]++'
}; export -f filter_uniq
Expand Down

0 comments on commit 1e0ca2a

Please sign in to comment.