aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGravatar KlzXS <azszwymmvqdi@yahoo.com>2020-03-11 13:20:55 +0100
committerGravatar GitHub <noreply@github.com>2020-03-11 17:50:55 +0530
commit29fe67b7995d0db5e96df6f949acc06c94a54e82 (patch)
treef864c24ffacf7b8deb7e4ff2d8029f30b5983e59 /plugins
parent233b801131e9e70a4ed1eac93c3481db22f5cbe5 (diff)
downloadnnn-29fe67b7995d0db5e96df6f949acc06c94a54e82.tar.gz
Addressing #489 (#490)
* Fix empty printf, change separator for sed * Added missing quotes
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/batchrename24
1 files changed, 13 insertions, 11 deletions
diff --git a/plugins/batchrename b/plugins/batchrename
index 23dc9a3..b22b9ae 100755
--- a/plugins/batchrename
+++ b/plugins/batchrename
@@ -42,14 +42,16 @@ while read -r num name; do
fi
printf "%s: unable to parse line, aborting\n" "$0"
+ exit 1
fi
# check if $num is an integer
if [ ! "$num" -eq "$num" ] 2> /dev/null; then
printf "%s: unable to parse line, aborting\n" "$0"
+ exit 1
fi
- src=$(eval printf "%s" "\${$num}")
+ src=$(eval printf "%s" "\"\${$num}\"")
if [ -z "$src" ]; then
printf "%s: unknown item number %s\n" "$0" "$num" > /dev/stderr
@@ -65,14 +67,14 @@ while read -r num name; do
c=1
new_args=""
while [ $c -le $# ]; do
- tmp=$(eval printf "%s" "\${$c}")
+ tmp=$(eval printf "%s" "\"\${$c}\"")
if [ "$c" -eq "$num" ]; then
new_args="$new_args ''"
else
if [ -z "$tmp" ]; then
tmp="''"
else
- tmp=$(printf %s "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
+ tmp=$(printf "%s" "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
fi
new_args="$new_args $tmp"
fi
@@ -103,15 +105,15 @@ while read -r num name; do
c=1
new_args=""
while [ $c -le $# ]; do
- item=$(eval printf "%s" "\${$c}")
+ item=$(eval printf "%s" "\"\${$c}\"")
if [ "$item" = "$name" ]; then
- item=$(printf %s "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
+ item=$(printf "%s" "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
new_args="$new_args $item"
else
if [ -z "$item" ]; then
item="''"
else
- item=$(printf %s "$item" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
+ item=$(printf "%s" "$item" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
fi
new_args="$new_args $item"
fi
@@ -134,11 +136,11 @@ while read -r num name; do
c=1
new_args=""
while [ $c -le $# ]; do
- tmp=$(eval printf "\${$c}")
+ tmp=$(eval printf "\"\${$c}\"")
if [ -z "$tmp" ]; then
tmp="''"
else
- tmp=$(printf "%s" "$tmp" | sed "s/^$src\(\$\|\/\)/$name\1/;s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
+ tmp=$(printf "%s" "$tmp" | sed "s|^$src\(\$\|\/\)|$name\1|;s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
fi
new_args="$new_args $tmp"
c=$((c+1))
@@ -153,14 +155,14 @@ while read -r num name; do
c=1
new_args=""
while [ $c -le $# ]; do
- tmp=$(eval printf "%s" "\${$c}")
+ tmp=$(eval printf "%s" "\"\${$c}\"")
if [ "$c" -eq "$num" ]; then
new_args="$new_args ''"
else
if [ -z "$tmp" ]; then
tmp="''"
else
- tmp=$(printf %s "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
+ tmp=$(printf "%s" "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
fi
new_args="$new_args $tmp"
fi
@@ -173,7 +175,7 @@ done <"$dst_file"
c=1
new_args=""
while [ $c -le $# ]; do
- tmp=$(eval printf "%s" "\${$c}")
+ tmp=$(eval printf "%s" "\"\${$c}\"")
if [ -n "$tmp" ]; then
rm -ri "$tmp"
fi