bin/74043: [PATCH] sh trap builtin does not properly quote when
listing
Jilles Tjoelker
jilles at stack.nl
Wed Nov 17 08:00:54 PST 2004
>Number: 74043
>Category: bin
>Synopsis: [PATCH] sh trap builtin does not properly quote when listing
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 17 16:00:53 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: Jilles Tjoelker
>Release: FreeBSD 6.0-CURRENT amd64
>Organization:
MCGV Stack
>Environment:
System: FreeBSD hammer.stack.nl 6.0-CURRENT FreeBSD 6.0-CURRENT #3: Mon Nov 1 18:36:46 CET 2004 marcolz at hammer.stack.nl:/usr/obj/usr/src/sys/HAMMER amd64
>Description:
When listing traps (invoking the trap builtin without arguments), /bin/sh
does not properly quote actions containing single quotes. This should be done
in such a way the output can be input into the shell later, but it is not.
>How-To-Repeat:
jilles at hammer /home/jilles$ /bin/sh
$ trap "echo 'jilles'" USR1 && trap
trap -- 'echo 'jilles'' usr1
$
>Fix:
There is already a function to output a string in a way it can be input back
later, so a patch is simple.
--- trap.c.diff begins here ---
--- src/bin/sh/trap.c.orig Wed Apr 7 10:12:45 2004
+++ src/bin/sh/trap.c Wed Nov 3 18:16:33 2004
@@ -153,15 +153,14 @@
if (argc <= 1) {
for (signo = 0 ; signo < sys_nsig ; signo++) {
if (signo < NSIG && trap[signo] != NULL) {
+ out1str("trap -- ");
+ out1qstr(trap[signo]);
if (signo == 0) {
- out1fmt("trap -- '%s' %s\n",
- trap[signo], "exit");
+ out1str(" exit\n");
} else if (sys_signame[signo]) {
- out1fmt("trap -- '%s' %s\n",
- trap[signo], sys_signame[signo]);
+ out1fmt(" %s\n", sys_signame[signo]);
} else {
- out1fmt("trap -- '%s' %d\n",
- trap[signo], signo);
+ out1fmt(" %d\n", signo);
}
}
}
--- trap.c.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list