mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +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
|
fi
|
||||||
|
|
||||||
printf "%s: unable to parse line, aborting\n" "$0"
|
printf "%s: unable to parse line, aborting\n" "$0"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if $num is an integer
|
# check if $num is an integer
|
||||||
if [ ! "$num" -eq "$num" ] 2> /dev/null; then
|
if [ ! "$num" -eq "$num" ] 2> /dev/null; then
|
||||||
printf "%s: unable to parse line, aborting\n" "$0"
|
printf "%s: unable to parse line, aborting\n" "$0"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
src=$(eval printf "%s" "\${$num}")
|
src=$(eval printf "%s" "\"\${$num}\"")
|
||||||
|
|
||||||
if [ -z "$src" ]; then
|
if [ -z "$src" ]; then
|
||||||
printf "%s: unknown item number %s\n" "$0" "$num" > /dev/stderr
|
printf "%s: unknown item number %s\n" "$0" "$num" > /dev/stderr
|
||||||
|
@ -65,14 +67,14 @@ while read -r num name; do
|
||||||
c=1
|
c=1
|
||||||
new_args=""
|
new_args=""
|
||||||
while [ $c -le $# ]; do
|
while [ $c -le $# ]; do
|
||||||
tmp=$(eval printf "%s" "\${$c}")
|
tmp=$(eval printf "%s" "\"\${$c}\"")
|
||||||
if [ "$c" -eq "$num" ]; then
|
if [ "$c" -eq "$num" ]; then
|
||||||
new_args="$new_args ''"
|
new_args="$new_args ''"
|
||||||
else
|
else
|
||||||
if [ -z "$tmp" ]; then
|
if [ -z "$tmp" ]; then
|
||||||
tmp="''"
|
tmp="''"
|
||||||
else
|
else
|
||||||
tmp=$(printf %s "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
|
tmp=$(printf "%s" "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
|
||||||
fi
|
fi
|
||||||
new_args="$new_args $tmp"
|
new_args="$new_args $tmp"
|
||||||
fi
|
fi
|
||||||
|
@ -103,15 +105,15 @@ while read -r num name; do
|
||||||
c=1
|
c=1
|
||||||
new_args=""
|
new_args=""
|
||||||
while [ $c -le $# ]; do
|
while [ $c -le $# ]; do
|
||||||
item=$(eval printf "%s" "\${$c}")
|
item=$(eval printf "%s" "\"\${$c}\"")
|
||||||
if [ "$item" = "$name" ]; then
|
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"
|
new_args="$new_args $item"
|
||||||
else
|
else
|
||||||
if [ -z "$item" ]; then
|
if [ -z "$item" ]; then
|
||||||
item="''"
|
item="''"
|
||||||
else
|
else
|
||||||
item=$(printf %s "$item" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
|
item=$(printf "%s" "$item" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
|
||||||
fi
|
fi
|
||||||
new_args="$new_args $item"
|
new_args="$new_args $item"
|
||||||
fi
|
fi
|
||||||
|
@ -134,11 +136,11 @@ while read -r num name; do
|
||||||
c=1
|
c=1
|
||||||
new_args=""
|
new_args=""
|
||||||
while [ $c -le $# ]; do
|
while [ $c -le $# ]; do
|
||||||
tmp=$(eval printf "\${$c}")
|
tmp=$(eval printf "\"\${$c}\"")
|
||||||
if [ -z "$tmp" ]; then
|
if [ -z "$tmp" ]; then
|
||||||
tmp="''"
|
tmp="''"
|
||||||
else
|
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
|
fi
|
||||||
new_args="$new_args $tmp"
|
new_args="$new_args $tmp"
|
||||||
c=$((c+1))
|
c=$((c+1))
|
||||||
|
@ -153,14 +155,14 @@ while read -r num name; do
|
||||||
c=1
|
c=1
|
||||||
new_args=""
|
new_args=""
|
||||||
while [ $c -le $# ]; do
|
while [ $c -le $# ]; do
|
||||||
tmp=$(eval printf "%s" "\${$c}")
|
tmp=$(eval printf "%s" "\"\${$c}\"")
|
||||||
if [ "$c" -eq "$num" ]; then
|
if [ "$c" -eq "$num" ]; then
|
||||||
new_args="$new_args ''"
|
new_args="$new_args ''"
|
||||||
else
|
else
|
||||||
if [ -z "$tmp" ]; then
|
if [ -z "$tmp" ]; then
|
||||||
tmp="''"
|
tmp="''"
|
||||||
else
|
else
|
||||||
tmp=$(printf %s "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
|
tmp=$(printf "%s" "$tmp" | sed "s/'/'\\\\''/g;s/^\(.*\)$/'\1'/")
|
||||||
fi
|
fi
|
||||||
new_args="$new_args $tmp"
|
new_args="$new_args $tmp"
|
||||||
fi
|
fi
|
||||||
|
@ -173,7 +175,7 @@ done <"$dst_file"
|
||||||
c=1
|
c=1
|
||||||
new_args=""
|
new_args=""
|
||||||
while [ $c -le $# ]; do
|
while [ $c -le $# ]; do
|
||||||
tmp=$(eval printf "%s" "\${$c}")
|
tmp=$(eval printf "%s" "\"\${$c}\"")
|
||||||
if [ -n "$tmp" ]; then
|
if [ -n "$tmp" ]; then
|
||||||
rm -ri "$tmp"
|
rm -ri "$tmp"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue