From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32029 invoked from network); 28 Nov 2021 20:32:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Nov 2021 20:32:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1638131538; b=UWZLqASecGooHm/CY4GLr59djQBdjGh4r+Ql8nw2RTWNu+jToQXhxU+sq+4bJwVD5imUzHc6NX 2vK2JUKmVXV92SEeaqa+MWfM4WviAxiYgwOsQEuaZeoI3YSUGF0vxUq9NoFeJPzBI7k2gPkWFN 0tM3FR1QyzmBDI2PSIi9mgwAjh5WUsjhHNzJNZl7rUo4rhlCbniDbL6imVtgU9QDaeUDukDtan hb/xWMSLrIjFYTExQYjIEIn2GZ/JwuKyfKDOe/ZNimweUGUiF74aFaQxVQB7xms6tzftAwmKm4 bpQZSWg+I4pVtSSSrSh2OBtkmd4JexKvw5Su76SPWzSIjg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-qt1-f182.google.com) smtp.remote-ip=209.85.160.182; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1638131538; bh=+bX2oByPqC5CCvf9ZodYuub1M7HH5dEm/+HSF6BfwaI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=CWKGEcDjFP0ahCwdLVVTg7mV1ZwvyFH2xqC9n2+RJNrbZCZmVPLpugELOpQOEkntsWv2V1yEwU AloeTzWtwIDfPI1pGmg+SZK4vvVbvJRbGVSOviy+8IxTevGFqgq5c7cYjQvWKjC61vdFNt/yF6 Oebm8jkMR0XmynTxGE7zy/UgbPKrgd1zyh6dYPOj4nCkAwRBoU1w2I/HqD1ZQb3xhKZDp8dS1V Iy3cEVJ341NUj7IiXNkt/XbNTvvJKsN9pGWS9reZpaWKXRWuzGHKpsSUxSgE+716JPG/kTmOoC pSqAECrZVFYEkMvzE6OkXU7JmKP2Rs5rgWM7ymZcCT4QJA==; 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:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=KxIXGr7sl765UNsYEcp8s80smllmd0mi//exco7+ySI=; b=NT/fFRu4Qpf2JVShQn5q4UDds/ 2Ea2rH7uE7qQ3nhXKsTibe8Z6980BPWhi1K5Cf0SFHoFYYLr2lSwmPKoByh0TEFfCwCQY2CFXftLn EuQAxn4CJfOJ9mDXjai3n8g86URPeD+nG8KgIxapy4Ao0uJ8VQ9faKZYpSjEFBzmPhpmtapFrr+ew x4VGX5crlwLsmMZf2KfSY8CXAexByPwUI7BakJGpKX0ZmDzhTqxpj+5pOnbkLz2WenGd3GmenMgVF Mld4Kg1th0HjQhQ3kL3nFa0FlMgamvsbqq80oiW1Y3vvJEgB2hGkZ8hvJ7nrnbDQeE3LVsN71PegI gfdrAQsQ==; Received: from authenticated user by zero.zsh.org with local id 1mrQqQ-000H0m-HS; Sun, 28 Nov 2021 20:32:18 +0000 Authentication-Results: zsh.org; iprev=pass (mail-qt1-f182.google.com) smtp.remote-ip=209.85.160.182; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-qt1-f182.google.com ([209.85.160.182]:41513) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mrQqF-000GiT-5D; Sun, 28 Nov 2021 20:32:07 +0000 Received: by mail-qt1-f182.google.com with SMTP id v22so14306328qtx.8 for ; Sun, 28 Nov 2021 12:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KxIXGr7sl765UNsYEcp8s80smllmd0mi//exco7+ySI=; b=CyZvGSMTk1It+e/3nXEHUftSWdp5MJ2GHJF+1691HNkc3BJp07hIMmFjw4yRu2Wg81 vfY8iTeAZR94bgp4lCfM8hbYzz+Tf/OBYtX4H3Z/FyjAldW1DOP7JQwxcOBB5HEsMXaD jkUNJ/jA6U3c4JQYuCRDlHyM60D1zcA/yIo+50RuRs7EroZ/gzlAf8p4Hpq7cxFW2T2m /WBs/DzODGAtwmVl8TNQu1LKs81+On9CuPZgfrNJfq5dvQJhQrhYY2EjUzsICtIPhDMQ a5kgvfRRfqVJIeHiieNAHdTAXeV+6pZwOldd9SRh4Uz2Ny8JGDrwleWCDUh2XCcwRvvY mFxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KxIXGr7sl765UNsYEcp8s80smllmd0mi//exco7+ySI=; b=2oOagHTkvbNF8c/PWAFPu/rROEruwJk79u2sCqjlQUGJIY5bIQC7SNHjw+fgeMqyX4 dsNzX1Ns/9aWd/NVX/GyZq5lu7Nj8ZEMVl/t8zLfycJD19/HLYP2gWV/lstKFBW0Ko3e GTVzewyUPiJaAZewAB6XQ390JkhEMUqP3N8qLjCrpJ+44VvVvEcOcOFqsLTU/9PYUdUo rVBvX6s+bBPIrJCAvxKwmUjsC2SoBu4aM9PR0MyLps2p4UVvk2p5d3n62jfNRzfVPiYn I62ylg8YaY880qmLQy04W7V3dOwhxH6QGRg9xIgqcFPCQhHicW6V6qTFFjwOhlEq7TGP xaZQ== X-Gm-Message-State: AOAM532Ip67Y/sFVNusD+ya2XpVtkWn0OUPNzl4/kruhIjOCXmzdjwVu O3yR4gActzzApdy5ZVwFiASxL/glDF7z8THS8wc= X-Google-Smtp-Source: ABdhPJygQNRLBBgH5hlSr0o2EBpcUyk6V6BX2qZTiyzC9KeFCUy7A6TDIPSsU8DihaauhPNMoPYjB4wz2PsE+WFbXYQ= X-Received: by 2002:ac8:5bc9:: with SMTP id b9mr30068270qtb.599.1638131525878; Sun, 28 Nov 2021 12:32:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Sun, 28 Nov 2021 21:31:54 +0100 Message-ID: Subject: Re: Prompt expansion on signals To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49610 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: On Sun, Nov 28, 2021 at 8:50 PM Bart Schaefer wrote: > > On Sun, Nov 28, 2021 at 2:01 AM Roman Perepelitsa > wrote: > > > > For this to work correctly, prompt_subst must be set when prompt is > > expanded. However, this requirement can be violated when prompt is > > expanded in a signal handler. > > A more egregious example might be when the global settings have > "unsetopt promptpercent". I can control these in my config. I cannot control options that are active when zsh processes SIGCHLD though (unless I never change options in zle widgets). To clarify, I'd like to: 1. Be able to resize my terminal and run background jobs. 2. Use zle widgets that set local_options and any other options together with it. 3. Never have my prompt expanded with wrong options. I don't know how to satisfy all three. If I drop the first point, then I do know. That is, I have control of shell options in all cases except when zsh expands prompt in a signal handler. These requirements look reasonable to me. Isn't it something that virtually everyone wants? I was surprised when I realized that I cannot have these things simultaneously (or don't know how). > Are prompts the only case where this is an issue, though? The most > visible, certainly, but "zle -F" for example? As far as I'm aware, prompt expansion on signals is the only place where it's impossible to set options. Perhaps I'm misunderstanding what you mean by "zle -F" in this context? > What about the reverse situation, where the signal handler is a > function that changes options locally? What do you mean? > > Prompt expansion can be affected by options other than prompt_*. > > Are you aware of any cases where this is true but prompt_subst is false? Hm... multibyte? There are also special parameters like LC_ALL that cause the same issue. For example, doing the following in a widget can break prompt if SIGCHLD arrives at the wrong moment: local LC_ALL=C ... > Either way that doesn't fix an explicit setopt of those. I sometimes change prompt_* options in functions when I want to use `print -P`. emulate -L zsh -o prompt_percent no_prompt_subst print -Pru2 -- '%F{1}error%f: missing required parameter: %F{3}--foo%f' This seemed smart at the time... What do you think about not running signal handlers for SIGCHLD and SIGWINCH while zle widgets are running? Postpone them. This already sort of happens when a signal arrives during recursive-edit. Roman.