what are the chances you actually need literal '%template' in cmd?
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
5675a08012
commit
ccad66749c
17
sx-open
17
sx-open
|
@ -107,7 +107,7 @@ error() {
|
|||
handle_target() {
|
||||
declare -n result=$1
|
||||
declare h cmd regex target_is_file target target_left cmd_is_template
|
||||
target_is_file=0
|
||||
cmd_append_target=1
|
||||
target=$2
|
||||
target_left=$target
|
||||
|
||||
|
@ -127,16 +127,13 @@ handle_target() {
|
|||
fi
|
||||
|
||||
while (( $# )); do
|
||||
cmd=( $1 ); regex=$2
|
||||
cmd=$1 regex=$2
|
||||
|
||||
for c in "${!cmd[@]}"; do
|
||||
if [[ "${cmd[c]}" == '%target%' ]]; then
|
||||
cmd_is_template=1
|
||||
cmd[c]="$target"
|
||||
fi
|
||||
done
|
||||
|
||||
(( cmd_is_template )) || cmd+=( "$target" )
|
||||
if [[ $cmd == *'%target%'* ]]; then
|
||||
cmd=( ${cmd//%target%/$target} )
|
||||
else
|
||||
cmd+=( "$target" )
|
||||
fi
|
||||
|
||||
if [[ "$target_left" =~ $regex ]]; then
|
||||
act "${cmd[@]}"; result=$?
|
||||
|
|
Loading…
Reference in New Issue
Block a user