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 7748 invoked from network); 28 Nov 2021 21:36:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Nov 2021 21:36:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1638135406; b=fZp7PLh01MO+ZyowqtyD/rV4HvdEeBg81JnjYLLE12ap6ESy38dJDDRN/AiRczES3S+xp2d5mw CqY2Ogo0O1EtrBcz1qyE9NrVbK59gxI60jKzSSKldfh+WTn/NtGiGn8A5rQAHhfu8rluHCO480 KQrX5/inqwpRjB57dE0ecBjERiySSe1sSjIXVdURcpMvx6WSgAxxJPp3jdF63PYlP+0ApgKaJa U/vv1TxupNS9/qRR6HrosIRNobBDlKYs0x+sC4Ms8qQ0WcKfd0Zzx1Ns+bUukbPJV/PLGcOxyT oDUVTZ4WRihUN5Hto/MTcu4dtDhG8wZO/zS6gygyYtTA2Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-qk1-f178.google.com) smtp.remote-ip=209.85.222.178; 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=1638135406; bh=GKCu22881gSisQGk2PE6ORzq2yivmPVuYytX/Ri8bXQ=; 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=jASUF4UCW8IqLMRcBpxsawXkYuqtvwpRRtqAPy7PX2/+hfr7fv1sVXjwErvMIUtsBqrxJjK4CP eAb5SXbuz0HbmMbnl5Ovw9vL0Ik4ppd8Pt1Q5LBASvQNObFlc+U3wmz7JzHSGGjVpZ7ihLiEli EWDp4cA4mEMhis3iJD9pa1YH7fuSDVXfT304tReTmB1L3I9yXvRdmTdvMU3i/m2MT+Oh9Fsm1P k6DTbIjeQz8YUJIAYP62dbeDl+D1fN7oUQdrUygtuz5hecgnUILp86aJzeS7ucBfFxcPPTq2AU lt+cUGkTdLre2OlCjJt5TUNdP4EJ4BFv9BtqJnKA+4nSZA==; 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=6oKGGKg6t5gGyvbv/Xd92t7Mm8ekyJgjDvL5m3LROyk=; b=swSyzgvTUGs2Y9GORCYybrBQpx 7sQYHZwGMgvg0GQovPYqeFJUHBEN0L/bkN8UHrZ5dNhrepRTW75Xw0HcW9NkpZdBClrLCLaaCYKdx x51OidqZIB9/bCI5LGRjvYVUzXATqoNmX3+b8tCdD86GpWOwrPSRP4rJ8xX7zs8euXGXBDlG1HwGg Hi7TL0A3SHrheZsQADftbfg4PDKjaMZEeEEF8JhC3/32tgjs4qDqzwD8wIkADXVL33OXMBCpFizjY h4ht8a4Em3UjoFGGT+vtEr2GAAsebun43ncqdzKuoEooveuyCDjoE4XgwLf3uh+WVN+F8A6cgqW/9 8EMgO9Kg==; Received: from authenticated user by zero.zsh.org with local id 1mrRqn-000KgD-RX; Sun, 28 Nov 2021 21:36:45 +0000 Authentication-Results: zsh.org; iprev=pass (mail-qk1-f178.google.com) smtp.remote-ip=209.85.222.178; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-qk1-f178.google.com ([209.85.222.178]:40519) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mrRqZ-000KMq-Lw; Sun, 28 Nov 2021 21:36:32 +0000 Received: by mail-qk1-f178.google.com with SMTP id p4so20680273qkm.7; Sun, 28 Nov 2021 13:36:31 -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=6oKGGKg6t5gGyvbv/Xd92t7Mm8ekyJgjDvL5m3LROyk=; b=BbXCv9lkA6QLHlx7w6MCcJjJA60i8ho7/fOYEAMSo/EIODvxYx5WEk/RjJDWyyX919 8HXK1cROJF3y4NdoSYtc/P93mgxoIojSNadxa2nLIzVJi+on81nE9wB384lEwhyrGlne SNko9XGDNObb1Lmt/WK2z4zZ1PKgkxqNtPpGi6rqLiiWmkTOcBiW0yZc8N4wtCkgCg67 JP8LrowDbz36Zmo72R5kty4BkqCXvJ4j7U9dIbqI0TRA9WBUwlTHSp6SSi/8iXPM1ERE mINy9JxCG4l5R0UchqK5CR+9EMqRo//tiRDei4lsD4APaHu5lEFI2+Bvt5ozdz5s6Qg9 ApQg== 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=6oKGGKg6t5gGyvbv/Xd92t7Mm8ekyJgjDvL5m3LROyk=; b=S+RrWThtN4AN9M72ak2xaBbGfaNvKcm4rxdNzIlzBdPNp1L0e7MFRHWiL1V0Pk8Dnv yWV1XTXSgjgRBCtWMlyM/08Uk06HachB+dtu0WLeljx0HYnMRJMNr5NYCaMgmFHjfc9z AzJpXvSrsWd/gz0tZ5CG/BW0cENtkF4w4id1apeqkZYZOxYwU8sYTcQ0NubR85+0070x moGA+TO0LcgjQQ83ZhYtpqMPsLihK9U70DeeBltJYS5SgucXgq/z7l4Ijvx4gfUkT8id mff3eIipHM8TRl9BJkzj6vC2FawDLRfaLFjC9xUDJEc2Sd0EJVQwxs+h9XTW2bTK5ec4 tmwA== X-Gm-Message-State: AOAM532QXF0ahtKM5AVr0CHE+xDCUw1eCtnvT+SEZvyRGEUgj9WNlhQ+ LGdHT4+eeCYSutKQamBdJFbd/nMNgyqtBR1wylLDBKX96UE= X-Google-Smtp-Source: ABdhPJwvatq1z3Hx7ar10KqGF2+NHbvJwvP+kEZ976Lr5Vsupz42u0773QSJWR44B/Ph1sp+Q+5W71Xmr/qMCTTAB6I= X-Received: by 2002:a37:9ec7:: with SMTP id h190mr26610738qke.700.1638135390073; Sun, 28 Nov 2021 13:36:30 -0800 (PST) MIME-Version: 1.0 References: <54317-1638133855.690561@cAWR.fGbz.m1n1> In-Reply-To: <54317-1638133855.690561@cAWR.fGbz.m1n1> From: Roman Perepelitsa Date: Sun, 28 Nov 2021 22:36:18 +0100 Message-ID: Subject: Re: Prompt expansion on signals To: Oliver Kiddle Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49614 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 10:10 PM Oliver Kiddle wrote: > > Roman Perepelitsa wrote: > > 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' > > In some cases, you might be better off using the ${(%)var} prompt > expansion. I do this in a few places. I'll probably need to replace all `print -P` calls with ${(%)} expansions. As a last resort I'm also considering removing all `emulate -L zsh` calls from all my code and not using any functions from third-parties or shipped with zsh, however awful that sounds. > It isn't necessarily just hooks and signal handlers that are affected. What do you mean by hooks? The only two places where I don't know how to control options is prompt expansion on SIGWINCH and SIGCHLD. Are there more? > Someone might want to use emulate in a zle widget directly. If this is a > plugin, and the author uses default prompt options, it mightn't be clear > to them that this could break for other users. What do you mean? Is it the same problem or a different one? Maybe we are talking about different things. Let's assume I'm in control of all my rc files and their complete transitive closure. I'm writing all widgets by hand. Every line of zsh code that executes in my shell is written by me. Given this assumption, I would like to avoid prompt expansion with wrong options. Right now the only way I know how to achieve this is to either give up perf-function options (via local_options + whatever options I want in the function) or to avoid triggering SIGWINCH and SIGCHLD (which implies never resizing my terminal and not using background jobs). > There are some cases in completion too where it'd be useful to restore > the user's option settings for a particular command. Perhaps we could > have an argument to emulate - user or global perhaps - for restoring the > original options. Would this help in avoiding prompt expansion with incorrect options? > Making options sticky when PS1, PS2 etc are set might break someone's > setup where they set their prompt before their options. Good point. Making options sticky also wouldn't avoid the issue where prompt is expanded with incorrect special parameters (LC_ALL, etc.). Overriding special parameters as locals in functions is convenient. It's a shame that it has the side effect of introducing a race that breaks prompt. Is there a downside to postponing the handling of SIGCHLD and SIGWINCH until all functions return? Postponing SIGWINCH seems safe but postponing SIGCHLD might blow up the job table. Is this a serious concern? Roman.