about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-03-26 09:45:47 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-03-26 09:45:47 -0700
commit1ea94513cc329c682d1afeaecd3bbfc3c66882ab (patch)
tree48da18a69410138f4f0a2c685da424d922b0e41f
parent21202e7b95b2b34446fbac34df67205b3889eed2 (diff)
downloadzsh-1ea94513cc329c682d1afeaecd3bbfc3c66882ab.tar.gz
zsh-1ea94513cc329c682d1afeaecd3bbfc3c66882ab.tar.xz
zsh-1ea94513cc329c682d1afeaecd3bbfc3c66882ab.zip
Dmitry Marakasov: 38162: accept G for gigabytes in limit command
from github pull request - some formatting edited
-rw-r--r--ChangeLog4
-rw-r--r--Doc/Zsh/builtins.yo1
-rw-r--r--Src/Builtins/rlimits.c6
3 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a763ba2d7..b2ca1ae95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-03-26  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* Dmitry Marakasov: 38162: accept G for gigabytes in limit command
+
 2016-03-21  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
 	* 38182: Completion/Unix/Command/_git: Invoke reflog completion
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index e3a6d564f..7083817bf 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1083,6 +1083,7 @@ startsitem()
 sitem(var(n)tt(h))(hours)
 sitem(var(n)tt(k))(kilobytes (default))
 sitem(var(n)tt(m))(megabytes or minutes)
+sitem(var(n)tt(g))(gigabytes)
 sitem([var(mm)tt(:)]var(ss))(minutes and seconds)
 endsitem()
 
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index 8b664e36a..29f97b41d 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -610,14 +610,16 @@ bin_limit(char *nam, char **argv, Options ops, UNUSED(int func))
 		return 1;
 	    }
 	} else {
-	    /* memory-type resource -- `k' and `M' modifiers are permitted,
-	    meaning (respectively) 2^10 and 2^20. */
+	    /* memory-type resource -- `k', `M' and `G' modifiers are *
+	     * permitted, meaning (respectively) 2^10, 2^20 and 2^30. */
 	    val = zstrtorlimt(s, &s, 10);
 	    if (!*s || ((*s == 'k' || *s == 'K') && !s[1])) {
 		if (val != RLIM_INFINITY)
 		    val *= 1024L;
 	    } else if ((*s == 'M' || *s == 'm') && !s[1])
 		val *= 1024L * 1024;
+	    else if ((*s == 'G' || *s == 'g') && !s[1])
+		val *= 1024L * 1024 * 1024;
 	    else {
 		zwarnnam(nam, "unknown scaling factor: %s", s);
 		return 1;