Print empty quotes ('') when an empty string is passed to outqstr().

This makes a difference for the trap builtin, where after "trap '' 0" we
printed "trap -- quit".  This is wrong, because an empty action means to reset
the action to the default.  A side effect of this commit is that empty
variables are now printed as "variable=''" instead of just "variable=".
This commit is contained in:
Stefan Farfeleder 2005-12-08 21:00:39 +00:00
parent 2a5e306d46
commit 3f0131f65b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153245

View File

@ -134,6 +134,10 @@ outqstr(const char *p, struct output *file)
{
char ch;
if (p[0] == '\0') {
outstr("''", file);
return;
}
if (p[strcspn(p, "|&;<>()$`\\\"'")] == '\0' && (!ifsset() ||
p[strcspn(p, ifsval())] == '\0')) {
outstr(p, file);