Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 502 #503

Merged
merged 2 commits into from
Jan 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions bin/git-changelog
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,20 @@ _exit() {
stty sane; echo; echo "caught signal, shutting down"

IFS=$'\n'
pid_list=( $(pgrep -P $$) )
# The format of `ps` is different between Windows and other platforms,
# so we need to calculate the total column number(COL_NUM) of header first.
# Why don't we just use the last column?
# Because the body of CMD column may contain space and be treated as multiple fileds.
pid_list=( $(ps -f |
awk -v ppid=$$ 'NR == 1 {
COL_NUM = NF
}
$3 == ppid {
# filter out temp processes created in this subshell
if ($COL_NUM != "ps" && $COL_NUM != "awk" && $COL_NUM !~ "bash$")
print $2
}')
)
IFS="$defaultIFS"

local _pid
Expand Down Expand Up @@ -465,7 +478,10 @@ main() {
rm -f "$tmpfile"
else
cp -f "$tmpfile" "$changelog"
[[ -n "$GIT_EDITOR" ]] && $GIT_EDITOR "$changelog"
# Use `eval` to handle GIT_EDITOR which contains space and options,
# like ""C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst ".
# Thanks @JanSchulz to inspire me this solution
[[ -n "$GIT_EDITOR" ]] && eval $GIT_EDITOR "$changelog"
if [[ $? -ne 0 ]]; then
_exit
fi
Expand Down