aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 444a6961b..9f1f8a4de 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6371,6 +6371,16 @@ subevalvar(char *p, char *str, int strloc, int subtype,
6371 6371
6372/* 6372/*
6373 * Add the value of a specialized variable to the stack string. 6373 * Add the value of a specialized variable to the stack string.
6374 * name parameter (examples):
6375 * ash -c 'echo $1' name:'1='
6376 * ash -c 'echo $qwe' name:'qwe='
6377 * ash -c 'echo $$' name:'$='
6378 * ash -c 'echo ${$}' name:'$='
6379 * ash -c 'echo ${$##q}' name:'$=q'
6380 * ash -c 'echo ${#$}' name:'$='
6381 * note: examples with bad shell syntax:
6382 * ash -c 'echo ${#$1}' name:'$=1'
6383 * ash -c 'echo ${#1#}' name:'1=#'
6374 */ 6384 */
6375static ssize_t 6385static ssize_t
6376varvalue(char *name, int varflags, int flags, struct strlist *var_str_list) 6386varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
@@ -6407,7 +6417,7 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
6407 return -1; 6417 return -1;
6408 numvar: 6418 numvar:
6409 len = cvtnum(num); 6419 len = cvtnum(num);
6410 break; 6420 goto check_1char_name;
6411 case '-': 6421 case '-':
6412 expdest = makestrspace(NOPTS, expdest); 6422 expdest = makestrspace(NOPTS, expdest);
6413 for (i = NOPTS - 1; i >= 0; i--) { 6423 for (i = NOPTS - 1; i >= 0; i--) {
@@ -6416,6 +6426,12 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
6416 len++; 6426 len++;
6417 } 6427 }
6418 } 6428 }
6429 check_1char_name:
6430#if 0
6431 /* handles cases similar to ${#$1} */
6432 if (name[2] != '\0')
6433 raise_error_syntax("bad substitution");
6434#endif
6419 break; 6435 break;
6420 case '@': 6436 case '@':
6421 if (sep) 6437 if (sep)