what are the chances you actually need literal '%template' in cmd?

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-07-27 20:43:04 +03:00
parent 5675a08012
commit ccad66749c

15
sx-open
View File

@ -107,7 +107,7 @@ error() {
handle_target() { handle_target() {
declare -n result=$1 declare -n result=$1
declare h cmd regex target_is_file target target_left cmd_is_template declare h cmd regex target_is_file target target_left cmd_is_template
target_is_file=0 cmd_append_target=1
target=$2 target=$2
target_left=$target target_left=$target
@ -127,16 +127,13 @@ handle_target() {
fi fi
while (( $# )); do while (( $# )); do
cmd=( $1 ); regex=$2 cmd=$1 regex=$2
for c in "${!cmd[@]}"; do if [[ $cmd == *'%target%'* ]]; then
if [[ "${cmd[c]}" == '%target%' ]]; then cmd=( ${cmd//%target%/$target} )
cmd_is_template=1 else
cmd[c]="$target" cmd+=( "$target" )
fi fi
done
(( cmd_is_template )) || cmd+=( "$target" )
if [[ "$target_left" =~ $regex ]]; then if [[ "$target_left" =~ $regex ]]; then
act "${cmd[@]}"; result=$? act "${cmd[@]}"; result=$?