Add debug output to tagtool
This commit is contained in:
parent
2097939aee
commit
513b377d56
@ -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.
|
||||
|
@ -15,7 +15,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
###
|
||||
|
||||
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*</tag>;>$newTagId</tag>;" "$f"
|
||||
if ! doVerbose sed -E -i "s;>\W*$oldTagId\W*</tag>;>$newTagId</tag>;" "$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*<tag\W*content=\"[^\"]*\"\W*>\W*$TagId\W*</tag>\W*;;i" "$f"
|
||||
if ! doVerbose sed -E -i "s;\W*<tag\W*content=\"[^\"]*\"\W*>\W*$TagId\W*</tag>\W*;;i" "$f"
|
||||
then
|
||||
echo "ERROR!" >&2
|
||||
return 1
|
||||
|
Loading…
Reference in New Issue
Block a user