• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3OLD="$1"
4NEW="$2"
5REALOLD="$1"
6
7# sanity check in input args
8if [ -z "$OLD" ] || [ -z "$NEW" ]; then
9    cat <<EOF
10Usage: $0 <old> <new>
11Changes the ADT plugin revision number.
12Example:
13  cd tools/eclipse
14  scripts/update_version.sh 0.1.2 0.2.3
15EOF
16    exit 1
17fi
18
19# sanity check on current dir
20if [ `basename "$PWD"` != "eclipse" ]; then
21    echo "Please run this from tools/eclipse."
22    exit 1
23fi
24
25# quote dots for regexps
26OLD="${OLD//./\.}\.qualifier"
27NEW="${NEW//./\.}\.qualifier"
28
29# Now find the same files but this time use sed to replace in-place with
30# the new pattern. Old files get backuped with the .old extension.
31grep -rl "$OLD" * | grep -E "\.xml$|\.MF$" | xargs -n 1 sed -i "" "s/$OLD/$NEW/g"
32
33echo "Remaining instances of $REALOLD"
34# do another grep for older version without the qualifier. We don't
35# want to replace those automatically as it could be something else.
36# Printing out occurence helps find ones to update manually.
37grep -r "$REALOLD" *
38
39