From jilles@stack.nl  Wed Nov 17 15:54:20 2004
Return-Path: <jilles@stack.nl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2879916A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Nov 2004 15:54:20 +0000 (GMT)
Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6963143D48
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Nov 2004 15:54:19 +0000 (GMT)
	(envelope-from jilles@stack.nl)
Received: from hammer.stack.nl (hammer.stack.nl [IPv6:2001:610:1108:5010::153])
	by mailhost.stack.nl (Postfix) with ESMTP id 4D0E51F27D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Nov 2004 16:54:18 +0100 (CET)
Received: by hammer.stack.nl (Postfix, from userid 1677)
	id 2F2C961D2; Wed, 17 Nov 2004 16:54:18 +0100 (CET)
Message-Id: <20041117155418.2F2C961D2@hammer.stack.nl>
Date: Wed, 17 Nov 2004 16:54:18 +0100 (CET)
From: Jilles Tjoelker <jilles@stack.nl>
Reply-To: Jilles Tjoelker <jilles@stack.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] sh trap builtin does not properly quote when listing
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         74043
>Category:       bin
>Synopsis:       [PATCH] sh trap builtin does not properly quote when listing
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    stefanf
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 17 16:00:53 GMT 2004
>Closed-Date:    Mon Dec 26 18:20:13 GMT 2005
>Last-Modified:  Mon Dec 26 18:20:13 GMT 2005
>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@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@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:
Responsible-Changed-From-To: freebsd-bugs->stefanf 
Responsible-Changed-By: stefanf 
Responsible-Changed-When: Thu Dec 8 18:20:07 GMT 2005 
Responsible-Changed-Why:  
I will take care of this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74043 
State-Changed-From-To: open->patched 
State-Changed-By: stefanf 
State-Changed-When: Thu Dec 8 20:09:22 GMT 2005 
State-Changed-Why:  
Fixed in current.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74043 
State-Changed-From-To: patched->closed 
State-Changed-By: stefanf 
State-Changed-When: Mon Dec 26 18:20:01 UTC 2005 
State-Changed-Why:  
Also fixed in RELENG_{5,6}. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74043 
>Unformatted:
