aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-01-25 20:50:11 +0100
committerVG <vg@devys.org>2016-01-25 20:50:11 +0100
commite7a8d9b69d459aaaa83204689a0e34862391035d (patch)
treeb59155dba2e28ebfa073d3821b1d3714ecf11eba
parent846f5ff2705fc38ea1b0ba74d2af54e2fb5a4579 (diff)
downloadbulkrename-e7a8d9b69d459aaaa83204689a0e34862391035d.tar.gz
bulkrename-e7a8d9b69d459aaaa83204689a0e34862391035d.tar.bz2
bulkrename-e7a8d9b69d459aaaa83204689a0e34862391035d.zip
reduce filename handling cornercases
be more robust if TMPDIR contains some unusual characters
-rwxr-xr-xbulkrename10
1 files changed, 4 insertions, 6 deletions
diff --git a/bulkrename b/bulkrename
index b030fa4..a927f9b 100755
--- a/bulkrename
+++ b/bulkrename
@@ -20,9 +20,8 @@ exec </dev/tty >/dev/tty || { echo 'Interactive terminal needed' >&2 ; exit 1; }
sed -i -- '1d' "${namebase}.2"
if [ $(wc -l < "${namebase}.1") -ne $(wc -l < "${namebase}.2") ] ; then
- rm -r "$(dirname "${namebase}")"
- echo "Wrong number of lines" >&2
- exit 1
+ rm -r -- "$(dirname -- "${namebase}")"
+ echo "Wrong number of lines" >&2 ; exit 1
fi
sed -i -- 's/\([\\"$`]\)/\\\1/g;' "${namebase}.1" "${namebase}.2"
@@ -35,10 +34,9 @@ sed -i -- 's/\([\\"$`]\)/\\\1/g;' "${namebase}.1" "${namebase}.2"
> "${namebase}.sh"
if [ "$(wc -c < "${namebase}.sh")" -ne 0 ] ; then
-
- "$EDITOR" "${namebase}.sh"
+ "$EDITOR" -- "${namebase}.sh"
sh -e -- "${namebase}.sh"
echo "bulkrename is done"
fi
-rm -r "$(dirname "${namebase}")"
+rm -r -- "$(dirname "${namebase}")"