From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27882 invoked by alias); 5 Jun 2016 16:35:59 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38615 Received: (qmail 5660 invoked from network); 5 Jun 2016 16:35:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=ROvW009NHbcb4YcufbDqKkrBJ3gqnlggyEWHJjk1s18=; b=PxMpJ0NSwiwZYBE0rok14HmrNy2kbx3DEKCDugL/qB7kzro39GzQmwj9Y4qGnNOhYJ mA6mG1b56Lq00icv0EUzvkQgckTjFDME6kTea2S5+h0aO+b8frLwwrwGHtWbFsYku3R7 H/z6NOZz8Dj6GYfcfvKgCzhDr5sf6dQLEGwUJEAg05sTKWzQrHT/8M9y+axT3CaAMGqL x/Nz2e2ZxbXqU+Q8GWAdwQ6I7FHB6ISy0g8fZxQdLp+FcsM5DMDasj3Y80QVsolLRaNE eiN/CT8nvM+mvFpkLic695P1sycNtXyf7xVf4cOoqMbI88utBFTeI54kV1e6dUAGRb0z NuNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=ROvW009NHbcb4YcufbDqKkrBJ3gqnlggyEWHJjk1s18=; b=ZZiXPCpnQ7oRVWByP9xtpT6BiqQ16jrB8DDuNP5C5x1TQ5kQKASngfeObusC2PjjUs iGJhKXdq9qhnM2r9qPzf82W/R7Oh/OdIQ+9zP7oq1FLsS88+a77kmi+eQw/jOjUvyyQf GVYddidiMzaXYUjGrmxv78J3Zs1GcuXf8Erb7nOReNBwO4mTN64mU5KYrLiXd+6WaT2D JmHB3KI8SihS6ev9q8JQmNmx5ea1R1o8lNFwQItmSD1aSC9aLhsnotqQvs++i9ceQOx/ QSgkd7qwxDtm5kenNqq46whuTdyX7BoYwD1GPMJ/Deg25pmY7iQGLefl0qi9q7cxrpE3 vKGQ== X-Gm-Message-State: ALyK8tLYXxSUC5MknNge0pJXdwLpbiCo7PD9mNEOC/ldw6ckSUGgHB46mec2gYh7G14bpg== X-Received: by 10.194.108.225 with SMTP id hn1mr11451315wjb.108.1465144555869; Sun, 05 Jun 2016 09:35:55 -0700 (PDT) To: zsh-workers@zsh.org From: Matthew Malcomson Subject: kill builtin argument parsing Message-ID: Date: Sun, 5 Jun 2016 17:35:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hello there, I recently mistakenly used arguments for the /bin/kill binary with the zsh kill builtin and noticed something strange that I think should be improved. The command line I used was: kill -1 -- which ends up killing the current Zsh process. This is because the pid valid argument check at Src/builtin.c:2572 uses isanum() that just asserts that all characters in the string are either '-' or a digit. When the string "--" is parsed as a digit with atoi() in Src/jobs.c:2572 it returns '0' which is passed to kill(2) syscall. I'm not sure whether to suggest changing the isanum() function, or the check in bin_kill() that relies on it. I would personally change the isanum() function, as a cursory reading of the two places it's used appear to not require this particular behaviour (the other place it's used in Src/jobs.c:2193 doesn't appear to have any negative consequences either way), but the comment above this isanum() function clearly shows it was a known behaviour, so there may be a reason I'm missing. Either way I think the behaviour is surprising enough and possible enough to be worth changing. Cheers MM