diff --git a/tools/tagtool/README.md b/tools/tagtool/README.md
index e961dd0e9e..e3e40e73b4 100644
--- a/tools/tagtool/README.md
+++ b/tools/tagtool/README.md
@@ -33,4 +33,6 @@ You can then fill the "action" field with the following actions:
A word of warning: you'll probably need to polish the results by hand a little
(removing empty lines, checking for duplicate tags introduced by renaming).
+## Debugging
+You can call tagtool.sh with the environment variable "VERBOSE" set to 1.
diff --git a/tools/tagtool/tagtool.sh b/tools/tagtool/tagtool.sh
index 7233d8339c..61570a65ed 100755
--- a/tools/tagtool/tagtool.sh
+++ b/tools/tagtool/tagtool.sh
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
###
-
TAGSDATAFILE="$1"
if [[ ! -f "$1" ]]
then
@@ -23,6 +22,19 @@ then
exit 1
fi
+# set to "1" to add verbose debug outpu
+VERBOSE=${VERBOSE:-0}
+
+doVerbose()
+# doVerbose CMD ARGS..
+{
+ if [[ VERBOSE -eq 1 ]]
+ then
+ echo "${@@Q}" >&2
+ fi
+ "$@"
+}
+
findTaggedFiles()
# findTaggedFiles TAG_ID
# grep for files containing the tag
@@ -41,7 +53,7 @@ renameTag()
for f in $(findTaggedFiles "$oldTagId")
do
echo "..$f" >&2
- if ! sed -E -i "s;>\W*$oldTagId\W*;>$newTagId;" "$f"
+ if ! doVerbose sed -E -i "s;>\W*$oldTagId\W*;>$newTagId;" "$f"
then
echo "ERROR!" >&2
return 1
@@ -59,7 +71,7 @@ removeTag()
for f in $(findTaggedFiles "$oldTagId")
do
echo "..$f" >&2
- if ! sed -E -i "s;\W*\W*$TagId\W*\W*;;i" "$f"
+ if ! doVerbose sed -E -i "s;\W*\W*$TagId\W*\W*;;i" "$f"
then
echo "ERROR!" >&2
return 1