blob: a2889659d7e06d77108727001b04ab31c8a33319 [file] [log] [blame]
The Android Open Source Project52d4c302009-03-03 19:29:09 -08001#!/bin/bash
2
3OLD="$1"
4NEW="$2"
5
6# sanity check in input args
7if [ -z "$OLD" ] || [ -z "$NEW" ]; then
8 cat <<EOF
9Usage: $0 <old> <new>
10Changes the ADT plugin revision number.
11Example:
12 cd tools/eclipse
13 scripts/update_version.sh 0.1.2 0.2.3
14EOF
15 exit 1
16fi
17
18# sanity check on current dir
19if [ `basename "$PWD"` != "eclipse" ]; then
20 echo "Please run this from tools/eclipse."
21 exit 1
22fi
23
24# quote dots for regexps
25OLD="${OLD//./\.}"
26NEW="${NEW//./\.}"
27
28# Find all the files with the old pattern, except changes.txt and
29# p4 edit them. Skip that if there's no p4 in path.
30if which g4 1>/dev/null 2>/dev/null ; then
31 grep -rl "$OLD" * | grep -E "\.xml$|\.MF$" | xargs -n 5 g4 edit
32fi
33
34# Now find the same files but this time use sed to replace in-place with
35# the new pattern. Old files get backuped with the .old extension.
36grep -rl "$OLD" * | grep -E "\.xml$|\.MF$" | xargs -n 1 sed -i.old "s/$OLD/$NEW/g"
37