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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18551 invoked from network); 7 Apr 2021 20:08:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Apr 2021 20:08:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617826135; b=kceB62c+NebbjcC/UlrJABshCrjxh9x4HKAqf+3+g6weycl7oFxz0TDzpnnv239Wzr5nTwed2H zYOAdK/9e1op438KaElzck7E0vAh97s4/VdFnzx60O4N7wllWwNzz9ybjfpr4K8c+mspuqsduO 2PnxNRaik7JRk8wipLAhuTwH4SPaWzxODYShhEjNAnWPake3ABWfDzPCGrMR1+Lr1mdcoLpYS1 XsEA8LadN+gbz3Rtw7WOSujr8JTajFoluACDekDn70B35EXxqQdy+aLnbPwfXneoVHs4WaVY6T SsebBI+bWSgB7hwRosJ3WEQCnchkkpKEp+M3/xXs7/s2IA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail.cs.msu.ru) smtp.remote-ip=188.44.42.39; dkim=tmperror (pubkey unavailable) header.d=altlinux.org header.s=dkim header.a=rsa-sha256; dmarc=none header.from=altlinux.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617826135; bh=eXuluJx4Hcy4KkOp7BsAEaGUU0IQ4vqvCToCjyx8lNQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Subject:In-Reply-To:Content-Type:MIME-Version:References: Message-ID:To:From:Date:DKIM-Signature:DKIM-Signature; b=YXmUpoxIHYrHER7CqbN6oca8hIaG+Y35s5PnMmS5Y9bSj6Xf1uDvYXOuNJ84oaEqvPD3nfAgtz hQVBIbHf+8mi3n3f+JSzf0Hmpe3LaYjiOyY6l1QDiRjalpgam4G73+suWylSBcyA3BXcLEwdYo 01tM1WYYY/x32AbNtVb+CuFteNLTF9N1VFeQHgfxFSoBqiiGD4GN76Ca7mgWaaGsYWM0+dMykF wR3W3aAm7I+ZyPszOPkUGWWJkK9rvwlnjzqMcWpWBbajlHqNWrphlzTci9xJ80/fjF/uExrw8O 18CdteS/uW6XrpiEeEgFsnoJKbO+90fgvdxnVC399FkcmQ==; 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:Subject:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2eZeHHu1yCtQpkdVkqGQjONucniuwIS0byQjssIYPEk=; b=dWX53z0vDBmZD9+qfTHAytZrc9 CvNOieiwkkElWOENCilRFi/q0sBRFIGTLeElG3x5dQ9rZ2fj2fkInDGCmp41ZQrh3w96WSDSvMs66 aas3WKweEUdBi4Gu3oa45x08EMqrJZ2MIWSuh8wg4ZMJFDNVIi9Dh26c3TdpG3/t+bov/b4sBwRuR PCPmHZ9I+b+m1ibo3ZMC8MEcLupSeXT8Ldn4OR2zacVyZacTckXNfPRStCT4HyuJYQaPGCkkdzJF9 /FC+LovuShJXZbOWJj1cTS0bOB0gUbURzgIB14FoPIYRcINQNPBCeymEeEebXdNImC3pZpbMVWRqU YMG+4blg==; Received: from authenticated user by zero.zsh.org with local id 1lUETu-000HwL-JF; Wed, 07 Apr 2021 20:08:54 +0000 Authentication-Results: zsh.org; iprev=pass (mail.cs.msu.ru) smtp.remote-ip=188.44.42.39; dkim=tmperror (pubkey unavailable) header.d=altlinux.org header.s=dkim header.a=rsa-sha256; dmarc=none header.from=altlinux.org; arc=none Received: from mail.cs.msu.ru ([188.44.42.39]:65422) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lUETg-000Hhg-4g; Wed, 07 Apr 2021 20:08:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=altlinux.org; s=dkim; h=Subject:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2eZeHHu1yCtQpkdVkqGQjONucniuwIS0byQjssIYPEk=; b=YS4QTeMVk3Ea0DgtbH6spLQhUH XSKf6uDKx92YibbALm0m+4RYNLOI29uHuOE58WFQzYcC2lNdooeSRXe515g0Nhye2u5EHNUHVQZ5b l56uDtz/MuHxYExXfGrnOik6BMoE2MR8QDKxpR/ZBbrJb0+4nceQZ21vFjJm50Am7evXPHuU5gukb kdFVrlGbo9wom8chAqK92lLxvRWtI3ZBASKIP9vopZW+b3V9AKkLlC9fPXgKZeUsPwuJPO/usOIh5 qauVPV4rAvOv16RGk7r6E0J/JF1SusCE2Mm+8SqTz5K9JCMZVYiJU4sj9UBSPMRurgKVdKQ/JLD0E NWF+2XJw==; Received: from [37.204.119.143] (port=36470 helo=cello) by mail.cs.msu.ru with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lUETe-000N2y-9K for zsh-workers@zsh.org; Wed, 07 Apr 2021 23:08:39 +0300 Date: Wed, 7 Apr 2021 23:08:31 +0300 From: Arseny Maslennikov To: Zsh hackers list Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="0xXbeqEj3HryFpgm" Content-Disposition: inline In-Reply-To: OpenPGP: url=http://grep.cs.msu.ru/~ar/pgp-key.asc X-SA-Exim-Connect-IP: 37.204.119.143 X-SA-Exim-Mail-From: arseny@altlinux.org Subject: Re: Rewrite of zsh-newuser-install (Mikael's subthread) X-SA-Exim-Version: 4.2.1 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) X-Seq: 48434 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: --0xXbeqEj3HryFpgm Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 07, 2021 at 08:15:18PM +0200, Mikael Magnusson wrote: > On 4/7/21, Marlon wrote: > > > >> On 5. Apr 2021, at 22.44, Mikael Magnusson wrote: > >> > >> On 4/5/21, Marlon Richert wrote: > >>> # > >>> # Type `zrestart` to safely apply changes after editing this file. > >>> # > >>> zrestart() { > >>> local zshrc=3D${ZDOTDIR:-$HOME}/.zshrc > >>> print -P "Validating %U$zshrc%u..." > >>> zsh -nf $zshrc || > >>> return > >>> > >>> print -P 'Restarting Zsh...' > >>> zsh -l && > >>> exit > >>> } There are two problems with `zsh -l && exit': 1) every zrestart invocation as written consumes PID space (so not really a restart); 2) if the last job of the last zsh in a zrestart chain has a non-zero exit status (e. g. WIFSIGNALED or falsey), and that zsh is ordered to exit, it will return that exit status, breaking the zrestart chain. The user would likely interpret this as "wow, my ^D doesn't work!". I don't know how to write zrestart in plain zsh robustly enough to be worthy of inclusion in the default .zshrc. Personally I just do alias zz=3D'exec zsh' or alias ZZ=3D'exec zsh' and that's it, but that's too minimalistic for a newbie tool. > >> > >> This could be an autoloadable function, not pasted verbatim in .zshrc. > >> Also disagree with -l here. You can use $options[login] or $- to see > >> if you're in a login shell already and start same. Things like this we > >> can't fix after users already copy this config. It should try to > >> mostly be configuration, not helper functions that can have permanent > >> flaws once installed. > > > > Sure, I can move it to an autoloadable function. That=E2=80=99s fine by= me. I did > > not come up with the -l, though. Earlier in the thread, Oliver & Bart d= idn=E2=80=99t > > like using `exec zsh` and offered this instead. See > > [48031](https://www.zsh.org/mla/workers/2021/msg00244.html). I=E2=80=99= d be happy to > > change it, but I don=E2=80=99t know how they feel about it. >=20 > You could also just have a comment saying something to the effect of > "changes to this file will only take effect in new shells, you can > either open a new terminal or type "zsh" in an existing terminal". I > guess I don't care too much either way after all. <...> > >>> # Auto-save last 20 dirs to file whenever we change dirs. > >>> # See > >>> http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Recent= -Directories > >>> autoload -Uz add-zsh-hook chpwd_recent_dirs > >>> add-zsh-hook chpwd chpwd_recent_dirs > >>> zstyle ':chpwd:*' recent-dirs-file ${ZDOTDIR:-$HOME}/.chpwd-recent-di= rs > >>> > >>> # On startup, initialize dir stack from file. > >>> autoload -Uz chpwd_recent_filehandler > >>> chpwd_recent_filehandler > >>> cd $reply[1] > >>> dirs $reply[@] >/dev/null > >> > >> Does this start zsh in some other directory than it inherited from the > >> terminal? If so, nak from me on that, way too surprising. > > > > It makes the shell pick up in the same dir as where you left off last t= ime. > > I would hardly call that surprising. In fact, I would pretty much call = that > > _expected_ for most applications nowadays. >=20 > I think most people on the list will strongly disagree with you here. Oh yes. When I was giving my (mostly positive or indifferent) feedback to Marlon privately on his request, I just ignored this part about dirstack at all, since I neither use it nor care about it. Making the shell chdir to a different directory every time is incredibly unintuitive to most Unix shell users. The runtime state restore functionality expected from applications does not apply here at all, because the shell is not an application, but a power tool. To expand on this: while a running application is usually a singleton in a given system, it's not uncommon for people to run about 10-15 fully independent shells for different tasks simultaneously. Consider the user logs out from such a session and then logs back in =E2=80= =94 the next shell they start will chdir to a directory last changed to by those 15 shells, and that directory is hard to keep track of. --0xXbeqEj3HryFpgm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE56JD3UKTLEu/ddrm9dQjyAYL01AFAmBuETkACgkQ9dQjyAYL 01ArDRAAmHc4OrgFkuPyWc8m/tDjDBw9SgIGFy+FJ7A6nCCEs6mDUGALZA/bU8gG KyXDLmWSkmysBImwZ7YLklJXK8sNbWhypJcitkVF+/Npzb/TKYWtDX25/jyyWZWs 497/dfxOWTHV7lS8KPlM1t/j5/rNzkQbTK19rQSgFFNHlZ9/3r6aHS94m25n8lcq E74hZpSiuwOtRyBEGu6VAAS5P+3jmOGWTf+poeHxqVsJBhLMrBAs+EwiQ977RLk+ KeJ/E25rkQC14g8F/4WhShxXQ5AfK0IYKP+hXZHnEXxdfCI3k7l1pPDxTqsKXVtR sbQi47nB77DNckjByssWsUsGtOJk9O3hVu6sgexk2P3SeK+NoF5K9cgxfsappcOP dG1VZ9jYb4kSUb9ae6RV4ciBYWV7Xqw5WQYu/IlB+7eYq/I3iXYXYs3neV201GxC mFhlW/BihQDXvSlQFssDPWe1ZCv6Ej0cvEXjAcWlYPln+n+dRKbtmH4uLssre/4z b60hEjU9qUWaddxVKozxw0lr93jzrkKZrodm1TSvAegaW7CNo/eg+30CBOIA/AAa SXMp20Kr/mhXH26GO501Hi18yRiAwbOKjkY8mYmNasL0DiWXOtShSR73G3tiuZ3o DzG/mMnBTwycze+xSB+ra01kJ9K+TerXJ8Lz1m+2690rZEiaQvY= =LlMK -----END PGP SIGNATURE----- --0xXbeqEj3HryFpgm--