From owner-freebsd-bugs@FreeBSD.ORG Wed Nov 17 16:00:54 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5652416A4D1 for ; Wed, 17 Nov 2004 16:00:54 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E6B643D4C for ; Wed, 17 Nov 2004 16:00:54 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id iAHG0r1L030934 for ; Wed, 17 Nov 2004 16:00:53 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id iAHG0rbe030928; Wed, 17 Nov 2004 16:00:53 GMT (envelope-from gnats) Resent-Date: Wed, 17 Nov 2004 16:00:53 GMT Resent-Message-Id: <200411171600.iAHG0rbe030928@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jilles Tjoelker Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2879916A4CE for ; 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 ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/74043: [PATCH] sh trap builtin does not properly quote when listing X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2004 16:00:54 -0000 >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@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: >Unformatted: