nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 29fe67b7995d0db5e96df6f949acc06c94a54e82
parent 233b801131e9e70a4ed1eac93c3481db22f5cbe5
Author: KlzXS <azszwymmvqdi@yahoo.com>
Date:   Wed, 11 Mar 2020 13:20:55 +0100

Addressing #489 (#490)

* Fix empty printf, change separator for sed

* Added missing quotes
Diffstat:
Mplugins/batchrename | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git 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