~emersion/mrsh

83a80e08da4cf8772d7cb10db7d2499075bb237e — Simon Ser 9 months ago 0264e7f
parser: disable aliases when processing command substitutions
1 files changed, 6 insertions(+), 0 deletions(-)

M parser/word.c
M parser/word.c => parser/word.c +6 -0
@@ 335,7 335,13 @@ static struct mrsh_word_command *expect_word_command(
	assert(symbol(parser, TOKEN));
	consume_symbol(parser);

	// Alias substitution is not allowed inside command substitution, see
	// section 2.2.3
	mrsh_parser_alias_func alias = parser->alias;
	parser->alias = NULL;

	struct mrsh_program *prog = mrsh_parse_program(parser);
	parser->alias = alias;
	if (prog == NULL) {
		if (!mrsh_parser_error(parser, NULL)) {
			parser_set_error(parser, "expected a program");