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,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21784 invoked from network); 2 Feb 2023 09:32:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Feb 2023 09:32:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1675330346; b=BTFJXr9geiZYBH8cn8B9FjIbsmZQq7B4vMFlal4DZAWYpyGdnXGAltHNQJlSgw1b+JK+e2vLPw uvteFeQr3KqBQIN7Inoh1Q9Byy68PB7D/RY9emAj9LgNa3LPx75m6ALOr9W/OvhZZvQYsq3hMB GkV+Z1yNXLoZXx5SZI0gOojtFUPmE+zZM7vU/VRJGBzgl8YLWEvzMrzWowGuwqEmMoiU+eXFSi /nuE7gMY7eA6ueJ8QUOTJACxr0rbShpPwuMmyo57lakKxTNFHzcfXnnl0GjasVFALGrBFM+0TW m72uYmW5A+/eIIX2aIUvJYKaz4BEGlrtkIFL97FMpC13cA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f173.google.com) smtp.remote-ip=209.85.208.173; 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=1675330346; bh=TAbatLEUvwR3VXYm6u2CI0mjk/RgP06u8LsL7IHr11M=; 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=i9/JFTEAVr2PpXT6XT/EU57IPzBl4rRZaRPXh6zwwpgJq4UGrgwUDMS28/lf+r5Y1aPlrXV3te NgZbWmvy9dvvmbJ3JZm1skaJP2YcP8EwbbkR2h5atzDXCSaiJVzFOnPHrylG3AV8aH/kTYhcdS LUWeA+YzYIQ6BhWIeQzklym3R3oEtBx9/s4A83NM48kF+2n2L0n3Uafu/XM7DZDOMkPMw56Smw C07OV/LT2/Nizk3m9cncJjFJImKjT6l5pmkNpo/1HagQGB/X6b/zPy7AUtV/e4+3Ag5E60nVox /M8q2aDf8JyV/wSLTiVyq5roMT8jjE5sHC+wv6Bwhq57fA==; 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=HLoQOAM6R9PxR4idg+RPKzf0xfAZ0OW2ECTssvdhCJM=; b=grEhCV3yudM6bg/cAu2cSZ3lR3 BS3/V5771WLN60AgVPZfkiCRiJy1AGrFjDzi/J/5hMhdRyAO47BTzDdtAft03wiakMCFeTmmZDCDk rV+SQZ9vygbHEDWodwAtkXHIqHQzVSm1t7Ia4zhxn91KvX70M3FULxUOuGgBIDHU9wz2XKKdMXlvn phenyCGE4KU+1UfIc9X/fdoil6/yMMGk+kJc2ZTjRyyzHiho8x9JCVk71eQiJv6S0VB0TwLl1wHRk ViMSy/qOLtJft4Wx++SnKXTsJyDqE7Xz8GIRzVvzNXVp25Aq3viUL0VI61jfjpY/HStphcdeGSGYx sB7BNq7Q==; Received: by zero.zsh.org with local id 1pNVxB-000FaN-Bn; Thu, 02 Feb 2023 09:32:25 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f173.google.com) smtp.remote-ip=209.85.208.173; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f173.google.com ([209.85.208.173]:35709) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pNVwu-000FHB-IZ; Thu, 02 Feb 2023 09:32:10 +0000 Received: by mail-lj1-f173.google.com with SMTP id h4so1269589lja.2 for ; Thu, 02 Feb 2023 01:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=HLoQOAM6R9PxR4idg+RPKzf0xfAZ0OW2ECTssvdhCJM=; b=aYiilI0SW7IEGc1Nb9Bc6gP/1lJvJ9/u9heE3m/psV1+yCXA44RAehw3FPQsqwQKif ltuokZ2tVNhyxtq12sNDlnp7bMfA/tD4uydOkHqdqTNYBv+Xstc/6o9agd0cqRIhETRl Qb8fKjVK4TRI18VRFNK0uIbGjkdjC5ya1TtkEETgjZv6eGbuZVnSZ06URGRa9pscUrrC 8nB98tKY+B7WxGaaS5D3Yy34/rQ2yCFIEibDX+M9soFDwLdOxy5S2xMkrszEIZjNmwUD GhK3NOFn1jYq9Ym+3wv2C5jAy+PwVK/u/qwxVDpQJrBUTZ/a5rD9l6ufAbVwV4icqcOR lYSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HLoQOAM6R9PxR4idg+RPKzf0xfAZ0OW2ECTssvdhCJM=; b=U8N7TItiya3a2jfeaAUY1fqKk90cRTPoFvw+f5PqKEoEgtoOoFxEnxueZWOEDyGHh0 hiLEsdT/05Dqd4MzhzBxKI9P9z4qVAxrL6N8l3V5K/TRu867TF9HZ0Xo8xEyd8KL9m0B Fs6pUQGMp2NXlVoLLulXAWD8CkE91xuHM9/49+tGTOb9SGLST07gx5z/t6sMT5pAbam9 oLyTXyp0vVU+tXQ9vpOsP8KoTd8DgGYGqXqktpAdQfswqVWaaVo3I+f2jBNSmf0MVV5a FSSS5Vl8EizMLXynbMdtbLo7kI7bvQx00toFwl0AGSxLm9I1D4tTFZfGJ2g3kmrpcRPt SU1g== X-Gm-Message-State: AO0yUKWmKqnKpphk7yE5QyFG3iw1MHja9Q4N5r2+qyQ5bXyHzEja3UkE IGuqrIJSPqBlBFzyEWWVxcsYoXyavGL05Le8S/0= X-Google-Smtp-Source: AK7set/SlYwX3UHHk6a+sOzqwiUTIlEHMxBoaEE3V4lhR0yF5iVFcGIGzI8O6wU4cisNsM6uCEHvSW4sVmYfqNAsv2w= X-Received: by 2002:a2e:878d:0:b0:290:7d76:ec59 with SMTP id n13-20020a2e878d000000b002907d76ec59mr879098lji.106.1675330327772; Thu, 02 Feb 2023 01:32:07 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Thu, 2 Feb 2023 09:31:41 +0000 Message-ID: Subject: Re: -C -like option to change CWD on startup To: Roman Perepelitsa Cc: Zsh hackers list Content-Type: multipart/alternative; boundary="00000000000011805505f3b43de6" X-Seq: 51347 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: --00000000000011805505f3b43de6 Content-Type: text/plain; charset="UTF-8" thanks for the interesting example. I would want to note two other programs that follow -C option convention, namely tar and env. The second can be even used to workaround the problem, i.e.: env -C ~/github zsh -c 'some commands' but still, a dedicated option would be good. On Thu, 2 Feb 2023 at 09:05, Roman Perepelitsa wrote: > On Thu, Feb 2, 2023 at 9:57 AM Sebastian Gniazdowski > wrote: > > > > Hi, > > make and git have the -C option which works like: > > ( > > builtin cd -q $COPT > > git/make "$@" > > ) > > > > I think that it is very useful, because no lengthy subshell is needed. > Zsh doesn't have such option, could it be added? It's pitty that -C is > already used by NO_CLOBBER, but maybe some other letter is free (I didn't > found any)? > > You can do this: > > zsh-in-dir() ( builtin cd -q -- "$1" && builtin exec zsh "${@:2}" ) > > This forks and execs once, the same as if there was a native `-C dir` > option. > > Note that your original code has the same performance thanks to an > optimization in zsh. The second fork is elided. > > Roman. > -- Best regards, Sebastian Gniazdowski --00000000000011805505f3b43de6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
thanks for the interesting example. I would want to note two= other programs that follow -C option convention, namely tar and env. The s= econd can be even used to workaround the problem, i.e.:

env -C ~= /github zsh -c 'some commands'

but still, a dedicated op= tion would be good.

On Thu, 2 Feb 2023 at 09:05, Roman Perepelitsa <= ;roman.perepelitsa@gmail.com= > wrote:
= On Thu, Feb 2, 2023 at 9:57 AM Sebastian Gniazdowski
<sgniazdowsk= i@gmail.com> wrote:
>
> Hi,
> make and git have the -C option which works like:
> (
>=C2=A0 =C2=A0 builtin cd -q $COPT
>=C2=A0 =C2=A0 git/make "$@"
> )
>
> I think that it is very useful, because no lengthy subshell is needed.= Zsh doesn't have such option, could it be added? It's pitty that -= C is already used by NO_CLOBBER, but maybe some other letter is free (I did= n't found any)?

You can do this:

=C2=A0 =C2=A0 zsh-in-dir() ( builtin cd -q -- "$1" && bui= ltin exec zsh "${@:2}" )

This forks and execs once, the same as if there was a native `-C dir` optio= n.

Note that your original code has the same performance thanks to an
optimization in zsh. The second fork is elided.

Roman.


--
Best regards,
Se= bastian Gniazdowski

--00000000000011805505f3b43de6--