zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Hahler <genml+zsh-workers@thequod.de>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Functions/Misc/relative: use -q with cd
Date: Thu, 22 Jun 2017 22:32:54 +0200	[thread overview]
Message-ID: <173fb4eb-4df7-a99d-7c49-9afca89b22bf@thequod.de> (raw)
In-Reply-To: <20170429170700.GA14300@fujitsu.shahaf.local2>


[-- Attachment #1.1: Type: text/plain, Size: 1233 bytes --]

On 29.04.2017 19:07, Daniel Shahaf wrote:

>> +++ b/Functions/Misc/relative
>> @@ -8,8 +8,8 @@ emulate -L zsh || return 1
>> -1=$(cd $1; pwd -r)
>> -2=$(cd $2; pwd -r)
>> +1=$(cd -q $1; pwd -r)
>> +2=$(cd -q $2; pwd -r)
> 
> Would «1=${1:P}» be equivalent?  (If it is, it saves a fork.)

Looks like it, I will adjust the patch before committing anything.


On 29.04.2017 21:47, Bart Schaefer wrote:
> On Apr 29,  5:07pm, Daniel Shahaf wrote:
> }
> } Pre-existing problem: should the function check that cd succeeded?
> 
> Aside from stderr messing up the display, are there any consequences
> for the completion result if failure is detected rather than ignored?

After looking closer at it, I think it would be better if it would work with non-existing files/dirs instead.

My use case is to make files that are relative to the .git dir relative to $PWD:

    for f in $files; do
      relfiles+=($(relative $gitdir/$f $PWD))
    done

And there it might be that the file does not exist anymore, since it was deleted.
I would still like to get the relative path in that case.
But then the magic of changing the first argument into a dir based on if it is a file will not work anymore obviously.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  parent reply	other threads:[~2017-06-22 20:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27 20:35 Daniel Hahler
2017-04-29 17:07 ` Daniel Shahaf
2017-04-29 19:47   ` Bart Schaefer
2017-06-22 20:32   ` Daniel Hahler [this message]
2017-06-22 23:39     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=173fb4eb-4df7-a99d-7c49-9afca89b22bf@thequod.de \
    --to=genml+zsh-workers@thequod.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).