Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Functions/Misc/relative: use -q with cd

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))

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: signature.asc
Description: OpenPGP digital signature

Messages sorted by: Reverse Date, Date, Thread, Author