On Sat, Feb 25, 2012 at 06:36:36PM +1100, Herbert Xu wrote: > On Tue, Feb 14, 2012 at 10:48:48AM +0000, harald@xxxxxxxxxx wrote: > > From: Harald Hoyer <harald@xxxxxxxxxx> > > "export -p" prints all environment variables, without checking if the > > environment variable is a valid dash variable name. > > IMHO, the only valid usecase for "export -p" is to eval the output. > Thanks a lot for the report and patch. > I'd prefer to fix this up at entry into the shell rather than > when we print out the variables. So how about this patch? Such a change would change other things than just "set" and "export -p". It would also not propagate environment variables with invalid names to child processes. For example: env -i not-a-name=1 PATH="$PATH" dash -c env | grep not-a-name Most shells pass the environment variable through, such as bash, zsh, ksh93 and most ash derivatives. However, the original Bourne shell and pdksh/mksh do not. I think it is best to pass them through so that executing a utility with and without the shell are as similar as possible (most versions of make(1) assume this is the case by skipping the shell if the command is simple enough) and particularly for dash for historical/compatibility reasons. I did something similar to the OP's patch in FreeBSD (SVN r223183): "set" and "export -p" skip variables with invalid names. Note that this problem cannot occur with "readonly -p" because only variables with a proper name can be marked read-only. -- Jilles Tjoelker -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html