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.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26382 invoked from network); 9 Aug 2023 22:49:23 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Aug 2023 22:49:23 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1691621364; b=Zor42ANrsw+wp21yd1ekjFfjDHGhNhUMqrmzp3H9h/WqvGLNvqqi3MPWvdZDM72sdvGXZaFjhd 3kOAodeYA9JC0yyF2ueHWb0387VXXttGFfdw1Me9amdyO1skgHBH+NTp2ZLBXlkjZNi4UX/TjZ y5oOVgdQEW5EXZWicenLOIctbTL+TEhdI97NwsrYkUAYeLC998VtWn8ScuFUENgMlj7DbOX2t1 osRELT5vQHr4Oyux35Fyjd+64R0bmq8NlwkrcEH0sYrCGpfVSGL20y1LKgO9rM8ozWllpAJSX5 bT3jMWjW0kAWUuCG2zjd1k5IaAeEFK68BvadfU3BkNn4Zg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (racky2.crushedhat.com) smtp.remote-ip=50.209.93.117; dkim=pass header.d=crushedhat.com header.s=default2k header.a=rsa-sha256; dmarc=pass header.from=crushedhat.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1691621364; bh=XgyGu6I7cOp1i/GBB/uqhhR5VVA3WBzll3zteI6cpcg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:Cc:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature:DKIM-Signature; b=r5jp0siSI5BH6yNnnBp7kV5zUjuO11Vq/AXNxIBZP5rQi0joU3OzcrjvpNfqmgNjcApreQdhAd HUjTOe0sNOF7b13vwDry8VPT2Y02vzFzZupvzXTrDwdCDThHQKGKIrg2QcLpHfQSDv2JIQZX5R m1YQRjWB8rERhm/mgbSzvBOYyFJHtO32kxXAFZFGbYksFmARY3I8Q168EV5+aoLAN8dCcUGsZn sFMLawDMaVXlELwd3mfCTecHVnVGpUtOYFBb/2Ddp5QzEBLZuwAtmlJe235mOuAs2o883ensmN LKzxc3aOaIdKZFCKs5ZI9mPXPOMlNNb+EchM3g+RSbIOUA==; 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:In-Reply-To:From:Cc:References:To: Subject:MIME-Version:Date:Message-ID:Content-Type:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=IVdUrrp9ttMPeWnKgqHGiqCC39pN+wx5yI801d7fzyo=; b=XfF6/bNZp0F+Tnvpw6IAICFKB6 mHcZLdogokf2/jJ/SPP1hUDC+awR35lLdmmdEQ8cjr8n1404D9dqFp9v2+H7wETnCqbdSx8Lnr1S2 ODk2BsxWUX2uuB8CBJDNnCfRxOPQUf41bm0zp3wDKqru5YvAy0VTYLGP0eLH+MixVulyMynio08Dq Z7PsW/6BaiWsFlv5TLyAUbgvAzbs4U1VG++8TjhszizAZ8B3on7QC5awoTplxuA14IOn+QWyfx1Fg MGEWRH0acn1ykKv9+VaqYieTr1oZBnLt4lqc9VxSa8CbSzEWSfQLeB2r3yiR6/Os4mPmL7dCntUgR xo6H7Jsg==; Received: by zero.zsh.org with local id 1qTrzW-000ERD-9u; Wed, 09 Aug 2023 22:49:22 +0000 Authentication-Results: zsh.org; iprev=pass (racky2.crushedhat.com) smtp.remote-ip=50.209.93.117; dkim=pass header.d=crushedhat.com header.s=default2k header.a=rsa-sha256; dmarc=pass header.from=crushedhat.com; arc=none Received: from racky2.crushedhat.com ([50.209.93.117]:49090) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1qTrzD-000E9z-Oh; Wed, 09 Aug 2023 22:49:05 +0000 DKIM-Filter: OpenDKIM Filter v2.11.0 racky2.crushedhat.com D93FA6F3441 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crushedhat.com; s=default2k; t=1691621340; bh=IVdUrrp9ttMPeWnKgqHGiqCC39pN+wx5yI801d7fzyo=; h=Message-ID:Date:MIME-Version:Subject:To:References:Cc:From: In-Reply-To:From; b=UfaX+kiZOdw/I2GzM3YIIPwbt4KOb5TUwetuR7Qm5iMca2XG3VSv+VuID3i57bHG5 oifvBi6pChYN4jVuCAQagGLkF3tOBBhe6raURfFCT3wsmzccHnrXoE9NAMDlEnmuch vEVvtTxQWWz5vurJ1dBAPVspjK18Q7DdLWdnPR+6ruoVoluNDY30cp48RbLtmci2Kn GXjwnI8Vk/cGv5/a6q/vx65+uThxGK5fGPIAj/ha0trpfECy9LEN5M0T69sC2Ldlnh 5yD1sgk+KR2APm2I5UqE0v2YcX7xyD7T5E/pKPHJqG+5LOQGZyaWZBBiMe00UCaK0b b6fsNax0Yt8aw== Received: from [IPV6:2603:3006:10c3:e100:e23f:49ff:feeb:21a3] (sheba-ipv6.crushedhat.com [IPv6:2603:3006:10c3:e100:e23f:49ff:feeb:21a3]) by racky2.crushedhat.com (Postfix) with ESMTPSA id D93FA6F3441; Wed, 9 Aug 2023 15:49:00 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------XtlCSh7BKEWcdrNBaku19i01" Message-ID: Date: Wed, 9 Aug 2023 15:49:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] Add option like tcsh's dextract Content-Language: en-US To: Mikael Magnusson References: <3a8e90b4-def1-bada-c118-68ddc1245972@crushedhat.com> <7105a328-a753-b5ce-0111-92e1b3fa781b@crushedhat.com> <8ac7f49d-3cb5-52b5-61ff-d5beff1bbb8a@crushedhat.com> Cc: zsh-workers@zsh.org From: Tim Eliseo In-Reply-To: X-Seq: 52041 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: This is a multi-part message in MIME format. --------------XtlCSh7BKEWcdrNBaku19i01 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2023-08-09 09:24:53, Mikael Magnusson wrote: > The manpage entry says: > This option makes tt(pushd) using `tt(PLUS())' or `tt(-)' behave > like tt(cd) with tt(AUTO_PUSHD) set. > > This is true as I understand it, but it somewhat implies that pushd > without +/- acts differently from cd, so perhaps it should just say > "This option makes pushd behave like cd with AUTO_PUSHD set.", which > is also true but harder to misinterpret. (I wouldn't oppose keeping it > as it is, it's just something that tripped me up while reading it.) I qualified this because pushd with no arguments _does_ act differently from cd. Pushd (without the pushd_to_home option set) swaps the top two directories on the stack, while cd always goes to the home directory, never swaps (with or without auto_pushd). Maybe a better rewording is something like “cd using + or - always extracts from the directory stack, never rotates it, regardless of the setting of this option.” In this way pushd becomes the reference point for stack manipulation (as it should be), instead of cd. The previous wording more belongs in the Changelog, since it’s describing what behavior is new relative to existing, something that is unimportant to a user reading the man page. > Another thought I had was that perhaps with this option existing, the > behavior between cd and pushd need not be different at all anymore, > but maybe someone prefers being able to extract with cd and roll with > pushd, so probably not worth messing with that. I personally don’t think that the + and - variants belong with cd at all, because with auto_pushd it’s too similar to pushd, and without auto_pushd the stack rearrangement doesn’t seem very intuitive or useful in either case (rotate or extract). Also the stack isn’t printed after the command. If you have a stack that looks like:     dir1 dir2 dir3 dir4 dir5 Current behavior of “cd +2” doing extract without auto_pushd ends up with:     dir3 dir2 dir4 dir5 A “cd +2” doing rotate without auto_pushd (not currently possible) might end up with:     dir3 dir4 dir5 dir2 Of course, we’re stuck with it now, but zsh is the only shell that has this. Also, as you said, someone might want to be able to use both extract and rotate options. > It would also be unclear which way the default should be in that case... > I think unquestionably the default for pushd should be rotate, since all other shells that implement pushd (csh, tcsh, bash, and fish) rotate, with only tcsh providing the dextract option to switch to extract. If we were to implement a separate cd_extract option, I say it should be set by default, to match current behavior. If the goal with this is to allow users to choose rotate or extract, we should also add command line options to override, which users can add to alias definitions. I’m going to think about this some more. I’ve been working on a cd and pushd feature matrix for all the shells, which I’ll post later. Tim --------------XtlCSh7BKEWcdrNBaku19i01 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 2023-08-09 09:24:53, Mikael Magnusson wrote:
The manpage entry says:
  This option makes tt(pushd) using `tt(PLUS())' or `tt(-)' behave
like tt(cd) with tt(AUTO_PUSHD) set.

This is true as I understand it, but it somewhat implies that pushd
without +/- acts differently from cd, so perhaps it should just say
"This option makes pushd behave like cd with AUTO_PUSHD set.", which
is also true but harder to misinterpret. (I wouldn't oppose keeping it
as it is, it's just something that tripped me up while reading it.)

I qualified this because pushd with no arguments _does_ act differently from cd. Pushd (without the pushd_to_home option set) swaps the top two directories on the stack, while cd always goes to the home directory, never swaps (with or without auto_pushd).

Maybe a better rewording is something like “cd using + or - always extracts from the directory stack, never rotates it, regardless of the setting of this option.” In this way pushd becomes the reference point for stack manipulation (as it should be), instead of cd. The previous wording more belongs in the Changelog, since it’s describing what behavior is new relative to existing, something that is unimportant to a user reading the man page.

Another thought I had was that perhaps with this option existing, the
behavior between cd and pushd need not be different at all anymore,
but maybe someone prefers being able to extract with cd and roll with
pushd, so probably not worth messing with that.

I personally don’t think that the + and - variants belong with cd at all, because with auto_pushd it’s too similar to pushd, and without auto_pushd the stack rearrangement doesn’t seem very intuitive or useful in either case (rotate or extract). Also the stack isn’t printed after the command. If you have a stack that looks like:

    dir1 dir2 dir3 dir4 dir5

Current behavior of “cd +2” doing extract without auto_pushd ends up with:

    dir3 dir2 dir4 dir5

A “cd +2” doing rotate without auto_pushd (not currently possible) might end up with:

    dir3 dir4 dir5 dir2

Of course, we’re stuck with it now, but zsh is the only shell that has this. Also, as you said, someone might want to be able to use both extract and rotate options.

It would also be unclear which way the default should be in that case...

I think unquestionably the default for pushd should be rotate, since all other shells that implement pushd (csh, tcsh, bash, and fish) rotate, with only tcsh providing the dextract option to switch to extract. If we were to implement a separate cd_extract option, I say it should be set by default, to match current behavior.

If the goal with this is to allow users to choose rotate or extract, we should also add command line options to override, which users can add to alias definitions.

I’m going to think about this some more. I’ve been working on a cd and pushd feature matrix for all the shells, which I’ll post later.

Tim

--------------XtlCSh7BKEWcdrNBaku19i01--