From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id ca1bdc48 for ; Mon, 1 Apr 2019 20:10:53 +0000 (UTC) Received: (qmail 26530 invoked by alias); 1 Apr 2019 20:10:38 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44198 Received: (qmail 7067 invoked by uid 1010); 1 Apr 2019 20:10:37 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f66.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25405. spamassassin: 3.4.2. Clear:RC:0(209.85.166.66):SA:0(-1.9/5.0):. Processed in 2.531952 secs); 01 Apr 2019 20:10:37 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.66 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=0BvCTm71R108wksxdPfhlIn6OCX4Bk5VFeSgJSvHtfU=; b=g1dYHm9OomQPIjAIpehgRSEqPWztnmvnXir7SY0aOXfM1Ihg2dcBiKHMFRNBJ7v4Pf 6TjYc3elDDWAiURqrDTFU9lGyl4OZFoBNtY+/n9TSOsEAWVoy44nOsXc0MWrmEH0bsra hsNTc5SPXFd64sBkuyKAGG9CpfHx1Oop5xwXVENIXMClqfCGGKuqroQBZ0Y3vgL0HIQ3 NahTfDTVuSB32joSS090hm1izT8eFMoYs2cZnUA+6XIQv0frLPLZTyNuTPB6UUPoBEmo anNJxpGoGYCD9QnhE/B8JbiFB0DAkxp85jV0LRRe3g+qiMfPLZYINurorN5235Rn/RJd 4XEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=0BvCTm71R108wksxdPfhlIn6OCX4Bk5VFeSgJSvHtfU=; b=q0i0O8fRV4Q+RN3OIYId7IEL2StwMqdmKk5JB7vGFqqPq5t6qpErANqutTvIC0R/+N 6ZlNGq2CEiyZJBeCxyuJwKILWUa3w6tKcm/MA/Ufu42lBmxN0bytyqJQzo0XUKNZz4E7 Qt2uJvSiaa4knIckqaHpd7c7/k0Dx7NSPLyKuYGc2m1l4LCAYFLPwLQcOHfDhXtJyinN 8rtzNG6qAGfSbbGEiARYqQLGASCYIGaF/GbZ4e1DM58VApugAFTJSa5ecpg30b8jGKNu h6CNeeFZip8hZ3fBdqBKapZQhwZBTP0cKlZR2/hA2Fd/8ku2WKFI24T8LyxoKHU0o1jW rULQ== X-Gm-Message-State: APjAAAXQCFAN84veqa9lF7/HjiSLwHlcDLEsy6wQqEK8CYed3lbuuSlH Xab+nLmWputj1LcWpoNKDHklR18ShIPJGg== X-Google-Smtp-Source: APXvYqxetH7CTYOHZ2AQ3uRufJ6eDSLaj9Dbjtx2i1YPgPnvyiwn4in6a5lZQqNOieuRL60yMws8Fw== X-Received: by 2002:a6b:3106:: with SMTP id j6mr1148200ioa.147.1554149401838; Mon, 01 Apr 2019 13:10:01 -0700 (PDT) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: [PATCH] Add cd_silent option Message-Id: <6B9849F1-F278-4735-B537-DDB8FC517B09@dana.is> Date: Mon, 1 Apr 2019 15:10:00 -0500 To: Zsh hackers list X-Mailer: Apple Mail (2.3445.9.1) This is a patch/e-mail i've been sitting on for a few months because i = wasn't sure if it was too niche. But it came up on IRC again, so: Someone on IRC complained about the way cd prints the working directory = in certain cases. I found a few other people asking about same: https://superuser.com/questions/565310/silent-cd-using-cdpath-with-zsh https://superuser.com/questions/1364512/dont-show-output-of-cd https://github.com/robbyrussell/oh-my-zsh/issues/6066 A patch was submitted a very long time ago to add an option to control = this: http://www.zsh.org/mla/workers/1996/msg01062.html It wasn't merged because, as pointed out in the reply, you can work = around it yourself by redirecting cd's stdout to /dev/null in an alias or = function. (You can also alias cd to pushd and set pushd_silent.) However, that doesn't = affect the implicit cd performed by auto_cd, which was the main issue the IRC = user had. It turns out Mikael has been patching his shell to suppress these = messages for over a decade, and the user was OK with doing that, but everyone seemed = to agree that an option would be nice too. So... here's that again, 22 = years later (Another solution would be to make auto_cd execute some function if it = exists, allowing the user to wrap cd however they want. But this seems = safer/easier?) dana diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index bc182eb7b..903c31134 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -88,6 +88,21 @@ tt(AUTO_CD) option set) is not a directory, and does = not begin with a slash, try to expand the expression as if it were preceded by a `tt(~)' = (see noderef(Filename Expansion)). ) +pindex(CD_SILENT) +pindex(NO_CD_SILENT) +pindex(CDSILENT) +pindex(NOCDSILENT) +cindex(cd, silencing) +cindex(autocd, silencing) +item(tt(CD_SILENT))( +Never print the working directory after a tt(cd) (whether explicit or +implied with the tt(AUTO_CD) option set). tt(cd) normally prints the +working directory when the argument given to it was tt(-), a stack = entry, or +the name of a directory found under tt(CDPATH). Note that this is = distinct +from tt(pushd)'s stack-printing behaviour, which is controlled by +tt(PUSHD_SILENT). This option overrides the printing-related effects of +tt(POSIX_CD). +) pindex(CHASE_DOTS) pindex(NO_CHASE_DOTS) pindex(CHASEDOTS) diff --git a/Src/builtin.c b/Src/builtin.c index 8dcdcc024..49f017046 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -720,7 +720,7 @@ bin_set(char *nam, char **args, UNUSED(Options ops), = UNUSED(int func)) /**** directory-handling builtins ****/ =20 /**/ -int doprintdir =3D 0; /* set in exec.c (for autocd) */ +int doprintdir =3D 0; /* set in exec.c (for autocd, cdpath, = etc.) */ =20 /* pwd: display the name of the current directory */ =20 @@ -1251,7 +1251,7 @@ cd_new_pwd(int func, LinkNode dir, int quiet) if (func !=3D BIN_CD && isset(INTERACTIVE)) { if (unset(PUSHDSILENT) && !quiet) printdirstack(); - } else if (doprintdir) { + } else if (unset(CDSILENT) && doprintdir) { fprintdir(pwd, stdout); putchar('\n'); } diff --git a/Src/options.c b/Src/options.c index 600b649e4..48c14c179 100644 --- a/Src/options.c +++ b/Src/options.c @@ -108,6 +108,7 @@ static struct optname optns[] =3D { {{NULL, "cbases", 0}, CBASES}, {{NULL, "cprecedences", OPT_EMULATE|OPT_NONZSH}, = CPRECEDENCES}, {{NULL, "cdablevars", OPT_EMULATE}, CDABLEVARS}, +{{NULL, "cdsilent", 0}, CDSILENT}, {{NULL, "chasedots", OPT_EMULATE}, CHASEDOTS}, {{NULL, "chaselinks", OPT_EMULATE}, CHASELINKS}, {{NULL, "checkjobs", OPT_EMULATE|OPT_ZSH}, CHECKJOBS}, diff --git a/Src/zsh.h b/Src/zsh.h index 10897372b..fc3ed2127 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -2348,6 +2348,7 @@ enum { CASEMATCH, CBASES, CDABLEVARS, + CDSILENT, CHASEDOTS, CHASELINKS, CHECKJOBS,