From patchwork Mon Dec 7 13:18:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Perkin X-Patchwork-Id: 7783781 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 92DD79F39B for ; Mon, 7 Dec 2015 13:18:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3D732045A for ; Mon, 7 Dec 2015 13:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6132203ED for ; Mon, 7 Dec 2015 13:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755207AbbLGNSi (ORCPT ); Mon, 7 Dec 2015 08:18:38 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:35027 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755046AbbLGNSi (ORCPT ); Mon, 7 Dec 2015 08:18:38 -0500 Received: by wmuu63 with SMTP id u63so140038026wmu.0 for ; Mon, 07 Dec 2015 05:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joyent.com; s=google; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=5Ii2jrDY9HuzAHcyY5Bt+B8neQIbN0mSt4JaoikkDQ0=; b=ZfGPoDa0Yx8ayyB4VWFYkUg8IJnzdNp90HMZRxhalqxrkfJ8vdcrCzErpruJxxNlfE 4LN1gcZeAB3FM6e1zQx66AgITa2rEMGE/fuzONCGv7wZrK5+iKUep9YLuSPIAmrBgQCx OLLGzVeB1/8H3ne4JA/o0aTuOdm54HvNj+CHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=5Ii2jrDY9HuzAHcyY5Bt+B8neQIbN0mSt4JaoikkDQ0=; b=ERDQxKvh5pFBBQqXcVR3aCSYZFySRoWi3uQzibnzlq9jEu5gKNHrujqYxlAhe1IizN MLENwRX3JIWf34Zxhc+YxoY0osr8JmsSQcnzivPvwx0OHUxkwtELFi2A1EFFVnpr0I+B LswxvfU4jZ3YpCYvXoK4a5TCOdhHGqLpwJ0H5XlcpxcHaqKvvKsXzhm47LA8WmV0ro2r xi7EZzt/8g7U8sZfXHmDUVSH3D/Q5jiW27L0WpYGIA/nIsBahTwPdLMChAOj9XhtbrWi GIvJ3w9RxxTPNLbbHfvTSMc+rcWOIMeU0YASoOfengwrxI6jKieJQA9FhP2E2SbOn36Y 8eYQ== X-Gm-Message-State: ALoCoQlkRcLM84M8hZ8b/6wqZPVPUlWldyxLzoQSZg0/kYSkkJSOBJ6MruZZNCoX7y/DDXDCzFGs X-Received: by 10.194.78.212 with SMTP id d20mr35847291wjx.70.1449494317202; Mon, 07 Dec 2015 05:18:37 -0800 (PST) Received: from joyent.com (host86-144-234-20.range86-144.btcentralplus.com. [86.144.234.20]) by smtp.gmail.com with ESMTPSA id s11sm16760914wmb.14.2015.12.07.05.18.36 for (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Dec 2015 05:18:36 -0800 (PST) Date: Mon, 7 Dec 2015 13:18:33 +0000 From: Jonathan Perkin To: dash@vger.kernel.org Subject: [PATCH] trap: Implement POSIX.1-2008 trap reset behaviour Message-ID: <20151207131833.GC735@joyent.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP POSIX.1-2008 for trap adds the following behaviour: If the first operand is an unsigned decimal integer, the shell shall treat all operands as conditions, and shall reset each condition to the default value. Whilst the standard specifies an "unsigned decimal integer", we take the pragmatic approach of enabling this behaviour iff the first operand is a valid signal, otherwise it is interpreted as an action. This matches the behaviour of most other shells in this regard. --- src/trap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trap.c b/src/trap.c index 82d4263..2d20c3f 100644 --- a/src/trap.c +++ b/src/trap.c @@ -112,7 +112,7 @@ trapcmd(int argc, char **argv) } return 0; } - if (!ap[1]) + if ((!ap[1]) || (decode_signal(*ap, 0) >= 0)) action = NULL; else action = *ap++;