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 = 0 ]; then
34 # An absolute path. This is fine.
37 # Expand tilde to $HOME
38 PATTERN
=$HOME$
(echo $PATTERN |
tail -c +2)
41 # A relaive path. Let's make it absolute.
47 if [ $COMPLETE_WORD = 1 ]; then
48 tr -cs '[:alnum:]_' '\n' |
49 grep "^$(basic_regex_quote "$PATTERN")." |
52 START
=$
(dirname "$PATTERN")
53 # The first path condition rules out paths that start with "." unless
54 # they start with "..". That way, hidden paths should stay hidden, but
55 # non-normalised paths should still show up.
60 -a -path "$(glob_quote "$PATTERN")*" \
63 head -n $FIND_FILE_LIMIT |
67 sed "s/^$(printf "%s
" "$PATTERN" | sed 's:/:\\/:g' )//" |