From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id B1E4928E23 for ; Tue, 27 Feb 2024 20:26:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2FHjq6NBZm7n5vuypOkUZeBf1ATUnYGKJrI+5UPX3qg=; b=OK40w10CUCaapdJ3Pq3Tj9MICy tV3QOBFo45PJCwyVoiek/IvZiYdN9qH6i/6BhDR0Uh2eIsEv0eS1DdHYk6NN/UID8NaX2EV4SE+Gb 7r5j/cURH5TZyEa0mw6u1j3vDFPqwvy36poFO6StmhTSUGSxY9DpIFYPF2WyfmzE/UXtb2lP71pBS 1QyVzLGWfzPJji53cDJFN1u/C91mkfnAusbWksZqMvKQxq6QS9lgbDvLdBnF1pIJE2S+8py0YXXcJ XA4JixIDd7/gqRWYtOB9UxytKQYLo9VzW+z/dgwx0eM/XKvyRn1qhWLggQZZMgAnuPeFKYR5ttT6J sKdl8MnA==; Received: by zero.zsh.org with local id 1rf35W-0006fF-1A; Tue, 27 Feb 2024 19:26:02 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rf34u-0006Jp-CP; Tue, 27 Feb 2024 19:25:25 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.97.1) (envelope-from ) id 1rf34t-000000003qn-1FKJ; Tue, 27 Feb 2024 20:25:23 +0100 cc: Zsh workers In-reply-to: From: Oliver Kiddle References: <73696-1708812060.096751@IRYQ.G6d0.hkDI> To: Bart Schaefer Subject: Re: PATCH: real-time signals support MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14803.1709061923.1@hydra> Date: Tue, 27 Feb 2024 20:25:23 +0100 Message-ID: <14804-1709061923.292710@qlv_.smDE.ovA0> X-Seq: 52622 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Bart Schaefer wrote: > It looks as if "kill -L" chooses the name with the smallest "absolute value"? Yes. Following the precedent of ksh and bash. > Some suggestions RE -L: I'm not especially attached to any particular format here. If you or someone else wants to change it I'm not going to object. I copied what bash and ksh do. The patch below handles the two easy suggestions but I'll wait for confirmation before applying. Is parsing kill -L output really that useful? > * Drop the right-paren after the signal number, so this output is easily parsed. > * List in columns first rather than across rows. I normally prefer columns first but with the RT signals, I think I actually prefer them at the bottom where they're easier to ignore. Ksh does this. I suspect they already have a general function for laying out tables. Perhaps we should factor out the part of print -C which does this so that it can be reused. > * Recognize terminal width and change number of columns. Ksh also does this. Not entirely to my taste on a wide terminal but I usually like my terminal windows narrow and tall anyway. > * Print one column (of number-name pairs, obviously) if output is not > a terminal. We don't adjust output for non-terminals from any other builtin. This can be annoying when you want to send the terminal form down a pipeline. > I know the "N) NAME" format is bash-reminiscent, but bash also puts > the "SIG" prefix on every name which this already does not. Anyway > two of those three suggestions are clearly a moderate amount of extra > effort, so just throwing out there. I couldn't see the point of the "SIG" prefix - adds no information but makes it harder to spot particular values. > Does this mean we should consider making $signals an associative array > like $history? That would remove the issue that $signals[2] = HUP, > etc., but maybe that's a backward-compat problem. It's probably too late to change. For converting between the two forms, ${ kill -l $sig } is more useful and the array works well enough as a source for completion. Incidentially, trying to use kill -l in that manner, it becomes apparent why the `...` and $(...) forms strip trailing newlines. Given that it aids compatibility with bash/ksh etc and updating old zsh scripts that use $(...) I'm not too sure that it preserving newlines is the most helpful behaviour. Parameter flags don't appear to work with the new form so adding one of those isn't an option. > Does that mean that Functions/Misc/zargs needs to change the way it > interprets exit status? There is a presumption that 129+ is "killed > by signal", that 255 is special, and that otherwise 254 is the largest > possible exit status. A greater range of values appear to be open to shell functions but otherwise, that sounds about right. There's also negative values. Oliver diff --git a/Src/jobs.c b/Src/jobs.c index 49decc661..bc9987513 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -2822,23 +2822,25 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) #else const int width = SIGCOUNT >= 100 ? 3 : 2; #endif + const int cols = isatty(1) ? 5 : 1; + for (sig = 1; sig < SIGCOUNT #if defined(SIGRTMIN) && defined(SIGRTMAX) + 1 #endif ; sig++) { - printf("%*d) %-10s%c", width, sig, sigs[sig], - sig % 5 ? ' ' : '\n'); + printf("%*d %-10s%c", width, sig, sigs[sig], + sig % cols ? ' ' : '\n'); } #if defined(SIGRTMIN) && defined(SIGRTMAX) for (sig = SIGRTMIN; sig < SIGRTMAX; sig++) { - printf("%*d) %-10s%c", width, sig, rtsigname(sig, 0), - (sig - SIGRTMIN + SIGCOUNT + 1) % 5 ? ' ' : '\n'); + printf("%*d %-10s%c", width, sig, rtsigname(sig, 0), + (sig - SIGRTMIN + SIGCOUNT + 1) % cols ? ' ' : '\n'); } - printf("%*d) RTMAX\n", width, sig); + printf("%*d RTMAX\n", width, sig); #else - printf("%*d) %s\n", width, sig, sigs[sig]); + printf("%*d %s\n", width, sig, sigs[sig]); #endif return 0; }