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 2373 invoked from network); 10 Jun 2021 17:45:38 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Jun 2021 17:45:38 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1623347138; b=YxiQXLLFih/bdO0Y1UhqjQiSXGedCjvDkTCUnueUfvhu1vAozFNDuCk2ykajmhAeltJ/E/GV1p DxyTBV8hMFJZs2fTk/yXtOw7twLnUEpFTYJch3z56aFTBgG8PcOchTZfq3NhteqKmDfXzfLFdM GPXOAbuyMhLDFUwHxwEvvgySesy5f5jrMIwVDqjud8CAur02i74KWiGHF3tWaJyG31jAuYcHHu DoiStnjbuybLDs2jqqA1fn7i3NaJSmEHywcEKXj+LxzPJ4y3cL3tKOas+tQ3z3S/zaJ15XLjCr CSYo0rluv29tq/zHQWksJzCh4/4pjByBFKdarn6MdROitw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f50.google.com) smtp.remote-ip=209.85.166.50; dkim=pass header.d=gmail.com header.s=20161025 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-20200801; t=1623347138; bh=0TuuKPHHeAvy6n331Oo1RxR3U4H+LjOKM59uwEavi3c=; 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=SiX8l3Wcqwy2PVTFWtsaDjK9AF8STwExom2kCrmxSYlTYf+b7upgdZFs8dKxoACybrAnPTZMFA IVOFkdg1SY35nmsvOB+d+oNuPf6im/3KpfGvdVZIJ9IrMtFeOycKcvadTopE37eDdMuh960z1u fE6vs0TNQa08bxFRYSNB9xDW9VG7Gg/0F73fv39Phf1C8GS+dOWVrsrqAVpVkecN6rDGeqEfve nRejO9fxQZO2DWZT1/8ILstumrbKN/+DjYuNoYHhzFmM/7t/jRbX/fJ0a/DQa0ctrBOrwaneWz cPNCNvh9wxen7+MjpdihLoPy1cskCrDqLk/jeCo8BusI/Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; 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=zjv8cdXvP/9lnyL8m9a7kKRXuu+/wofI+vaPEfxbr6c=; b=LXw07PtAkArWHKSfRMfUTH/Zql a3p0U7YIx9/+Dv5Bgei33NhytJq4s1fDVgqiGxdGD4X4l3XyVMmu3J8LQLqBnTzPJe57G3H0vpCMO pWdH6qFghAZ5b+DyCuWbksSKCC+HIa1q0i8jst8vduGjTXmxrVxkT6CoKgO9382Dy8ffSSwjuxUmm WJKSFeL1Pqfz3pMagQ6oHIp5CnRp3QgjL/k07oebD+errmE/EaI2cBrJf5Ku/zDmwZwseleVP8JuV wavZolLhZC1z2g6pEd/q/N8gPb3pMyl9Z9BG51su++dKz0Xj4PjNi7eVYw9Ym0WdtcRGjSnfKqqKj sJzVj1PA==; Received: from authenticated user by zero.zsh.org with local id 1lrOkM-000OQ0-Dj; Thu, 10 Jun 2021 17:45:38 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f50.google.com) smtp.remote-ip=209.85.166.50; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f50.google.com ([209.85.166.50]:39630) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lrOk4-000O9n-OD; Thu, 10 Jun 2021 17:45:21 +0000 Received: by mail-io1-f50.google.com with SMTP id f10so13434636iok.6 for ; Thu, 10 Jun 2021 10:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zjv8cdXvP/9lnyL8m9a7kKRXuu+/wofI+vaPEfxbr6c=; b=Hs08EQTA4WIgVIEhEy8PAL4DoidnAP1SBhxpUMQgu2TDVFOYnIuZPxcAWC4XSiHTk3 MciQH3v40e5fZkR8cBVJn+yybtuc+SM0QYoyGKYLdz69byqvQOsIItRr1waV+nzBhPEp Y7wb02KW3G2VnUgLJNw92UxPa8D0ytJQKKG1Ui4EGuDPWiI0ZhB9jldOfwiGPFqkMY1O OdFcBVtXYP9y8HgTYGXcy3vwlgn6udfarmttcBcNfLUzkBLh5wLdO5/vuqb02g/DaRKq KGUu9uVRlOgoCGCUoCLN2M26a2/IBQ75225nIy5PP3cgPyD91UFvMbyKF9JSILubwXOT uK+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zjv8cdXvP/9lnyL8m9a7kKRXuu+/wofI+vaPEfxbr6c=; b=myT7VeLloZ7hWSMI5OpULBTtACH0TKtIlyTuMuEeKJk0y5m0KNdO1YDG6XdpJ4T84a 7Qv44D3+zXjmFjmK11nAP1Rl0DEKeeAjVShlB+xi3tAcbBnVnThZEycEkewK7oMCCCLg ba5D5cnwctzVl3PHW9dWrTcTpog1MEBp0jynVj/iO9BeG07lOVzgjJKBRcKD3E+d3KLz z4S0R4SwVQI77e3DwQmZAyLECb+1OzkMOkEnsK/n3A9O6omv/5A3zPXEs38zM8N2UaWe gzImw7xxjhJ2sCMa1u3nK/YOrbsgB8Vy0KGdhPjSUpy3mI/5f9rjJTkvdEq6yOEoBIt9 odJw== X-Gm-Message-State: AOAM531zmcCm5Ov3BKVnlA53BAL464qV0WZGgtRVLWid+RqhPjw0CVTv 1uf897Hfc9bscEf3XUSaDa8RR4WBdq1z1xU9VtM= X-Google-Smtp-Source: ABdhPJyHdJk96CUv+dbLMctt8IFOMFWW3PU9LjovGkncF/eGdStIj8tM8UzIdeSDstiFihboFkK4o/tregzylxEtli4= X-Received: by 2002:a02:354d:: with SMTP id y13mr5781060jae.83.1623347119227; Thu, 10 Jun 2021 10:45:19 -0700 (PDT) MIME-Version: 1.0 References: <7E71FA83-356E-448B-9726-02DF3FF5BD14@gmail.com> <873D08A9-F321-474A-8440-CCE7DCCBA529@gmail.com> <20210414120551.GA3882@tarpaulin.shahaf.local2> <6CEA4F3E-9A64-44E1-9121-FA9D5E053AB5@gmail.com> <20210414140909.GG3882@tarpaulin.shahaf.local2> <29E16F69-B09E-44BF-9009-1CF53053D4FC@gmail.com> <20210416171321.GC4535@tarpaulin.shahaf.local2> <93FFDA3D-3C4A-414E-9220-1032ECE5B04C@gmail.com> <20210416193037.GD15670@tarpaulin.shahaf.local2> <9dc589f1-65b6-48b7-a7cb-81f9e2e16795@www.fastmail.com> <48174137-a8a7-4171-bcda-0899ebc19433@www.fastmail.com> <8082812e-b595-403b-9c8c-8956b6af08cd@www.fastmail.com> In-Reply-To: From: Roman Perepelitsa Date: Thu, 10 Jun 2021 19:45:07 +0200 Message-ID: Subject: Re: [PATCH] Add customizable `vcs` prompt theme (was Re: [RFC][PATCH] `newuser` prompt theme) To: Marlon Richert Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49056 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 Thu, Jun 10, 2021 at 3:48 PM Marlon Richert wrote: > > Thanks again. New version of the patch attached. Thanks! A few more comments/questions. Those that I'm not quoting can be considered resolved. > On Thu, Jun 10, 2021 at 12:30 PM Roman Perepelitsa > wrote: > > > > I think invoking prompt_vcs_setup twice in the same shell will produce > > an error. I haven't tried it though. > > I just tried it and I didn't get any errors. Why do you think it would > produce an error? I was expecting the readonly parameter at the top to print an error. % readonly -gHA _prompt_vcs_ps1_default=() % readonly -gHA _prompt_vcs_ps1_default=() zsh: read-only variable: _prompt_vcs_ps1_default It's also unclear to me whether this prompt supports clean deinitialization and repeated initialization. Doesn't look like it. Does it? > > Why is prompt_vcs_precmd checking whether prompt_vcs_fd is a readable > > fd? How can it not be? > > I don't know how or why, but if I don't check for that, then I get > this error repeatedly: > > prompt_vcs_precmd:6: failed to close file descriptor 11: bad file descriptor Then the check must be masking a bug. This bug can result in the closing of another file descriptor that is not owned by prompt_vcs. I took a quick look and perhaps the bug is due to prompt_vcs_fd-widget not unsetting prompt_vcs_fd? > > There is a comment in prompt_vcs_precmd that says it's going to kill a > > process while in fact it closes the file descriptor. That may > > *eventually* kill the process when it decides to print something > > (assuming it hasn't blocked SIGPIPE or is checking for write errors). > > True. I'll change it to actually kill the process, too. I see that the code is sending SIGKILL now and not waiting for the process to terminate. Both of these make me nervous. The code also *looks like* it would work without monitor but it wouldn't (it would result in unbounded background processes and zombies). What do you think about not killing anything and ensuring that at most one background process runs at once? This is what I do in my zsh theme and it works well. > > prompt_vcs_fd-widget has a check for [[ -n $1 ]]. When is it false? > > When prompt_vcs_fd-widget is being called incorrectly. :) When can it be called incorrectly? This is not a public function, it's a callback that is passed to `zle -F`. Do you expect the latter to violate its contract in this specific way? If not, I would remove the check. It's increasing the complexity of the code without material gain. > Perhaps it should not return 1 in that case, though. The return code of `zle -F` callbacks is ignored. Adding specific return codes makes it appear as if they matter. This makes the code harder to understand similarly to conditions that are always false. The file descriptor leaks to child processes. It's better to avoid this. This can be done by using sysopen with cloexec instead of plain exec. Instead of printing the pid and reading it in the parent you can use $sysparams[procsubstpid]. Why does _prompt_vcs_info quote its output? If it didn't quote, then there would be no need to unquote after reading. Handling errors from `read` would be nice. Roman.