| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Usage:
|
| 4 | # tools/find//run.sh <function name>
|
| 5 |
|
| 6 | set -o nounset
|
| 7 | set -o pipefail
|
| 8 | set -o errexit
|
| 9 |
|
| 10 | readonly REPO_ROOT=$(cd $(dirname $0)/../.. && pwd)
|
| 11 |
|
| 12 | find-demo() {
|
| 13 | echo
|
| 14 | echo --- "$@" ---
|
| 15 | echo
|
| 16 |
|
| 17 | # Add 'tools' dir to prevent it from walking the whole repo
|
| 18 | PYTHONPATH="$REPO_ROOT:$REPO_ROOT/vendor" \
|
| 19 | $REPO_ROOT/tools/find/find.py tools "$@"
|
| 20 | }
|
| 21 |
|
| 22 | unit-tests() {
|
| 23 |
|
| 24 | find-demo -true
|
| 25 | find-demo -false -o -true
|
| 26 | find-demo -true -a -false
|
| 27 |
|
| 28 | find-demo -name '*.py'
|
| 29 |
|
| 30 | # implicit -a
|
| 31 | find-demo -name '*.py' -print
|
| 32 | find-demo -printf "%P\n" -print
|
| 33 |
|
| 34 | find-demo -type f
|
| 35 | find-demo -type f ',' -name '*.py'
|
| 36 |
|
| 37 | # comma operator
|
| 38 | # find-demo -type f -a -print , -type d -a -print
|
| 39 |
|
| 40 | find-demo -type f -a -name '*.py' -a -print
|
| 41 |
|
| 42 | find-demo '(' -type f -o -type d ')' -a -name 'py'
|
| 43 | find-demo '(' -type f -o -type d -a -name 'py' ')'
|
| 44 |
|
| 45 | find-demo -type f -a -exec echo {} ';'
|
| 46 |
|
| 47 | find-demo -type f -a -fprintf out '%P\n' -a -quit
|
| 48 |
|
| 49 | find-demo -type f -a -name '*.py'
|
| 50 |
|
| 51 | find-demo '!' -name '*.py'
|
| 52 | }
|
| 53 |
|
| 54 | "$@"
|