~blake-rouse/maas/fix-1353597-1.6

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
# Copyright 2012 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# Exit immediately if a command exits with a non-zero status.
set -o errexit
# Treat unset variables as an error when substituting.
set -o nounset

cat <<EOF
This will normalize spelling of MAAS to either 'MAAS' or 'maas'
depending on the capitalization of the first letter. It pays no heed
to word boundaries, and will process *all* files in the tree. This
means two things:

1. Think very hard before using this on a tree with uncommitted
   changes.

2. Review the changes *carefully* before committing them. At _least_
   run the test suite.

EOF

read -e -p "Do you really want to run this? [yes/no] " yes_or_no

if [ "${yes_or_no}" == "yes" ]
then
    bzr ls -VR --kind=file --null \
        | xargs -r0 grep -Iil maas --null \
        | xargs -r0 sed -i 's/M[Aa][Aa][Ss]/MAAS/g;s/m[Aa][Aa][Ss]/maas/g'
fi