diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-04 03:14:41 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-04 03:14:41 +0200 |
commit | 4d8873f997053aa08c5932594b4078846115b861 (patch) | |
tree | 2632797bba9d4a5d1c842cbeca0ff73e0a449ac2 | |
parent | b618dba10345db75b6dc6ba2c9a7218e97044934 (diff) | |
download | busybox-w32-4d8873f997053aa08c5932594b4078846115b861.tar.gz busybox-w32-4d8873f997053aa08c5932594b4078846115b861.tar.bz2 busybox-w32-4d8873f997053aa08c5932594b4078846115b861.zip |
ash: document where we accept invalid syntax. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 18 |
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 | */ |
6375 | static ssize_t | 6385 | static ssize_t |
6376 | varvalue(char *name, int varflags, int flags, struct strlist *var_str_list) | 6386 | varvalue(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) |