4 basic_regex_quote
() { printf "%s" "$1" |
sed 's|[\\.*^$[]|\\&|g'; }
5 glob_quote
() { printf "%s" "$1" |
sed 's|[\\?*[]]|\\&|g'; }
11 while [ $# -gt 0 ]; do
14 echo "usage: $(basename "$0") [-h] [--file|--word] [pattern]"
31 if [ $COMPLETE_WORD = 1 ]; then
32 tr -cs '[:alnum:]_' '\n' |
33 grep "^$(basic_regex_quote "$PATTERN")." |
36 # Expand to absolute path because of the -path option below.
42 XPATTERN
=$HOME$
(echo $PATTERN |
tail -c +2)
45 XPATTERN
=$PWD/$PATTERN
49 # The first path condition rules out paths that start with "." unless
50 # they start with "..". That way, hidden paths should stay hidden, but
51 # non-normalised paths should still show up.
52 find $
(dirname "$XPATTERN") \
56 -a -path "$(glob_quote "$XPATTERN")*" \
59 head -n $FIND_FILE_LIMIT |
61 sed "s|^$(dirname $XPATTERN)/||"
64 sed "s|^$(basename $PATTERN)$(echo $PATTERN | tail -c 2 | fgrep /)||" |