Skip to content

Commit

Permalink
Reworked previous fixes on empty arrays.
Browse files Browse the repository at this point in the history
To check for lengths explicitly, given they were initialized to () at first.
  • Loading branch information
kjkuan committed Mar 5, 2017
1 parent 5f17fc3 commit 274166e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions taskit
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,14 @@ taskit_parse_args_of_tasks() {

if [[ $sigil = % ]]; then
declare -Ag "${task_args[$param]:=${param}_$(( RANDOM + TASKIT_SID__++ ))}=()"
local i=0
for arg in "${unknown[@]:-}"; do
[[ $arg ]] || continue
name=${arg%%=*} value=${arg#*=}
printf -v "${task_args[$param]}[$name]" "%s" "$value"
unset 'unknown[i++]'
done

if (( ${#unknown[*]} )); then
local i=0
for arg in "${unknown[@]}"; do
name=${arg%%=*} value=${arg#*=}
printf -v "${task_args[$param]}[$name]" "%s" "$value"
unset 'unknown[i++]'
done
fi
else
# if the parameter in the spec has no corresponding argument
if [[ " ${!task_args[*]} " != *" $param "* ]]; then
Expand Down Expand Up @@ -617,12 +617,13 @@ _taskit_run_task_with_args () {
local pattern opts=$-; set -f
local patterns=(${TASKIT_TASK_EXCLUDES:-})
set +f; set -${opts//[is]}
for pattern in "${patterns[@]:-}"; do
[[ $pattern ]] || continue
if [[ $task == Task::${pattern#Task::} ]]; then
return 0
fi
done
if (( ${#patterns[*]} )); then
for pattern in "${patterns[@]}"; do
if [[ $task == Task::${pattern#Task::} ]]; then
return 0
fi
done
fi

if [[ ${args_dict[no args]:-} && ${TASK_ATTRS[$task@noargs_status]:-} = 0 ]]; then
taskit_log DEBUG "$task (noargs) had been completed successfully, skipping..."
Expand Down

0 comments on commit 274166e

Please sign in to comment.