Module Name: src Committed By: kre Date: Mon Oct 21 15:57:45 UTC 2024
Modified Files: src/bin/sh: expand.c parser.c parser.h Log Message: Fix processing of unknown variable expansion types. Our shell is (was) one of the last not to do this correctly. Expansions are supposed to happen only when the command in which they occur is being executed, not while it is being parsed. If the expansion only happens them, errors should only be detected then. Make it work like that (I saw after I fixed this that FreeBSD had done it, long ago, almost the same way - it is kind of an obvious thing to do). This will allow code like if test it is shell X then commands using shell X specific expansion ops else if it is shell Y then commands using shell Y specific expansion ops else ... fi Previously expansion errors were detected while parsing, so if we're not shell X, and don't implement something that it does (some extension to the standard) that would have generated a parser syntax error, and the script could not be executed (despite the line with the error never being executed). Note that this change does not handle all such possible extensions, just this one. Others are much harder. One side effect of this change is that sh will now continue reading a variable expansion until it locates the terminating '}' (in ${var} forms) regardless of how broken it obviously is (to our shell) whereas previously it would have bailed out as soon as an oddity was spotted. To generate a diff of this commit: cvs rdiff -u -r1.145 -r1.146 src/bin/sh/expand.c cvs rdiff -u -r1.183 -r1.184 src/bin/sh/parser.c cvs rdiff -u -r1.29 -r1.30 src/bin/sh/parser.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.