ew.py: disable XHCI and USB tablet on arm32/icp
[helenos.git] / tools / srepl
blob76ffd98c05600981dac9f3cac45a25fec8371242
1 #!/bin/sh
3 function usage {
4 echo "Usage:"
5 echo
6 echo " $0 search_pattern [-- <pathspec> ]"
7 echo " $0 search_pattern replacement [-- <pathspec> ]"
8 echo
9 echo "Pattern should be a basic regexp as accepted by grep and sed."
10 echo "For information on pathspec syntax, see git documentation."
11 echo
12 exit 1
16 if [ "$1" == "--" ]; then
17 usage
18 elif [ "$#" -eq 1 ] || [ "$2" == "--" ]; then
19 pattern="$1"
20 shift
21 git grep -I -n "$pattern" "$@"
22 elif [ "$#" -eq 2 ] || [ "$3" == "--" ]; then
24 if ( git status --porcelain | grep '^.[^ ]' ); then
25 echo "You have unstaged changes in your tree."
26 echo "Either stage them with 'git add', commit them,"
27 echo "or discard them with 'git checkout -- .'"
28 exit 1
31 pattern="$1"
32 replacement="$2"
33 shift
34 shift
35 git grep -I -l "$pattern" "$@" | xargs sed -i "s/$pattern/$replacement/g"
36 else
37 usage