mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
* Fix empty printf, change separator for sed * Added missing quotes
This commit is contained in:
parent
233b801131
commit
29fe67b799
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue