diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-11-23 11:10:16 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-11-23 11:10:16 +0100 |
commit | 7077bc737a34da664e6771bba7eee18aa60d1c6d (patch) | |
tree | d959972012f6cd174b9d3e41e90356e0f5a8e847 | |
parent | 28b092d1e0b29e07f71f28bdb7bf7ffba465210c (diff) | |
download | scripts-7077bc737a34da664e6771bba7eee18aa60d1c6d.tar.gz |
git-log-describe: Fix filedescriptors leak
-rwxr-xr-x | git-log-describe.awk | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/git-log-describe.awk b/git-log-describe.awk index c0ab37e..1ab3a98 100755 --- a/git-log-describe.awk +++ b/git-log-describe.awk @@ -21,7 +21,9 @@ BEGIN { if (!cache_dir && cache) { # Use directory in .git/ as default. - "git rev-parse --show-toplevel" | getline cache_dir; + cmd = "git rev-parse --show-toplevel"; + cmd | getline cache_dir; + close(cmd); if (cache_dir) cache_dir = cache_dir "/.git/describe-cache.d"; } @@ -91,7 +93,9 @@ function git_describe(hash) { desc = ""; if (length(hash) != 40) { - "git rev-parse --default " hash | getline hash; + cmd = "git rev-parse --default " hash; + cmd | getline hash; + close(cmd); if (length(hash) != 40) return ""; } @@ -106,7 +110,9 @@ function git_describe(hash) { # cache entry was unavailable, get a description now. if (!desc) { - "git describe " opts " " hash " 2>/dev/null" | getline desc; + cmd = "git describe " opts " " hash " 2>/dev/null"; + cmd | getline desc; + close(cmd); # write description to cache if allowed. if (cache_dir && desc && !cache_ro) { |