Skip to content

Commit

Permalink
Merge pull request #349 from zplug/fix-348
Browse files Browse the repository at this point in the history
Fix #348
  • Loading branch information
zplug-man committed Jan 6, 2017
2 parents 951e74d + 8deef6e commit 41d7983
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/job/process.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ __zplug::job::process::get_status_code() {
fi

cat "$_zplug_log[$target]" \
| grep "^repo:$repo\t" \
| awk '{print $2}' \
| cut -d: -f2
| __zplug::utils::awk::ltsv \
'key("repo")=="'"$repo"'"{print key("status")}'

return $status
}

Expand Down
21 changes: 21 additions & 0 deletions base/utils/awk.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,24 @@ __zplug::utils::awk::available()
return 1
fi
}

__zplug::utils::awk::ltsv()
{
local \
user_awk_script="$1" \
ltsv_awk_script

ltsv_awk_script=$(cat <<-'EOS'
function key(name) {
for (i = 1; i <= NF; i++) {
match($i, ":");
xs[substr($i, 0, RSTART)] = substr($i, RSTART+1);
};
return xs[name":"];
}
EOS
)

awk -F'\t' \
"${ltsv_awk_script} ${user_awk_script}"
}

0 comments on commit 41d7983

Please sign in to comment.