aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-04 03:14:41 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-04 03:14:41 +0200
commit4d8873f997053aa08c5932594b4078846115b861 (patch)
tree2632797bba9d4a5d1c842cbeca0ff73e0a449ac2
parentb618dba10345db75b6dc6ba2c9a7218e97044934 (diff)
downloadbusybox-4d8873f997053aa08c5932594b4078846115b861.tar.gz
ash: document where we accept invalid syntax. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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,
/*
* Add the value of a specialized variable to the stack string.
+ * name parameter (examples):
+ * ash -c 'echo $1' name:'1='
+ * ash -c 'echo $qwe' name:'qwe='
+ * ash -c 'echo $$' name:'$='
+ * ash -c 'echo ${$}' name:'$='
+ * ash -c 'echo ${$##q}' name:'$=q'
+ * ash -c 'echo ${#$}' name:'$='
+ * note: examples with bad shell syntax:
+ * ash -c 'echo ${#$1}' name:'$=1'
+ * ash -c 'echo ${#1#}' name:'1=#'
*/
static ssize_t
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)
return -1;
numvar:
len = cvtnum(num);
- break;
+ goto check_1char_name;
case '-':
expdest = makestrspace(NOPTS, expdest);
for (i = NOPTS - 1; i >= 0; i--) {
@@ -6416,6 +6426,12 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
len++;
}
}
+ check_1char_name:
+#if 0
+ /* handles cases similar to ${#$1} */
+ if (name[2] != '\0')
+ raise_error_syntax("bad substitution");
+#endif
break;
case '@':
if (sep)