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