37e7c073c6f0365ed8255c83168835503c5e1921 — Simon Ser 26 days ago dd5a12c
shell/task/word: refuse to apply string param ops on $#

Refuse to apply string parameter operations on $#, except the string length
operator.
1 files changed, 3 insertions(+), 1 deletions(-)

M shell/task/word.c
M shell/task/word.c => shell/task/word.c +3 -1
@@ 313,7 313,9 @@ case MRSH_PARAM_DPERCENT:
  		case MRSH_PARAM_HASH:
  		case MRSH_PARAM_DHASH:
- 			if (strcmp(wp->name, "@") == 0 || strcmp(wp->name, "*") == 0) {
+ 			if (strcmp(wp->name, "@") == 0 || strcmp(wp->name, "*") == 0 ||
+ 					(wp->op != MRSH_PARAM_LEADING_HASH &&
+ 					strcmp(wp->name, "#") == 0)) {
  				fprintf(stderr, "%s: using this parameter operator on $%s "
  					"is undefined behaviour\n",
  					ctx->state->frame->argv[0], wp->name);