summaryrefslogtreecommitdiffstats
path: root/bin/sh/output.c
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-12-08 21:00:39 +0000
committerstefanf <stefanf@FreeBSD.org>2005-12-08 21:00:39 +0000
commit0dcfd185aff80e3d2e75ab6f9c203126f3311c1b (patch)
treee0a9d5586f013cd9acd95e6d19423535dd10a1af /bin/sh/output.c
parente308dfd9647221dc2fcb2186edde86ac30ed2c6c (diff)
downloadFreeBSD-src-0dcfd185aff80e3d2e75ab6f9c203126f3311c1b.zip
FreeBSD-src-0dcfd185aff80e3d2e75ab6f9c203126f3311c1b.tar.gz
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=".
Diffstat (limited to 'bin/sh/output.c')
-rw-r--r--bin/sh/output.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/sh/output.c b/bin/sh/output.c
index 3550cb7..b59e11e 100644
--- a/bin/sh/output.c
+++ b/bin/sh/output.c
@@ -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);
OpenPOWER on IntegriCloud