aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 705fe9fa4..90fb00fbd 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6411,7 +6411,15 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
6411 len = number(loc); 6411 len = number(loc);
6412 } 6412 }
6413 } 6413 }
6414 if (pos >= orig_len) { 6414 if (pos < 0) {
6415 /* ${VAR:$((-n)):l} starts n chars from the end */
6416 pos = orig_len + pos;
6417 }
6418 if ((unsigned)pos >= orig_len) {
6419 /* apart from obvious ${VAR:999999:l},
6420 * covers ${VAR:$((-9999999)):l} - result is ""
6421 * (bash-compat)
6422 */
6415 pos = 0; 6423 pos = 0;
6416 len = 0; 6424 len = 0;
6417 } 6425 }