Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Symlinks in recursive glob
- X-seq: zsh-users 23743
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: <zsh-users@xxxxxxx>
- Subject: Re: Symlinks in recursive glob
- Date: Mon, 5 Nov 2018 09:52:17 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181105095220euoutp02013d555174d8cd8110ded5cca161135b~kMaEJ2Cca1789317893euoutp02V
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541411540; bh=ENUXA5X9ewh4zIhLpZ/5FvFhhavwJADOveoBs9cjG6o=; h=Subject:From:To:Date:In-Reply-To:References:From; b=gUWd/s7x8NJnDQY5zT2FJikJ+7w1gIb6iq5eJOuiqgJkgP1g/1CcCji4Fk0nknYPg jd2n/8lNDfbYeIxCGp7++vhs4RR4CJuT4QdRgENx1/+cmDsbblpccqIi7pvWh+CPNi GZs//8VKiSXLRyvuzsVZaQS6vM/0hstAAs5LzED0=
- In-reply-to: <CAJjRh0Sq-onqU+jJfvD2-m7iFXEJaO8par3+eWGXhqHK0QJV0Q@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20181105001937epcas3p2ebd558b47eca5ed019b8762a91e96b96@epcas3p2.samsung.com> <CAJjRh0Sq-onqU+jJfvD2-m7iFXEJaO8par3+eWGXhqHK0QJV0Q@mail.gmail.com>
On Mon, 2018-11-05 at 01:17 +0100, Dominik Ritter wrote:
> Hi all,
>
> is there a way to not dereference symlinks in a recursive glob?
>
> Long story:
> I want to search upwards for a file like
> `print (../)#.shorten_folder_marker(:a:h)`, but that dereferences symlinks.
> If I remove the :a modifier I get a relative path, which I cannot use as
> well. The use case is that I want to truncate the folder to the point where
> the .shorten_folder_marker exists. This may be a symlinked directory.
> e.g. I have /tmp/test/1/2/3 and /tmp is a symlink to /private/tmp.
You can't do this directly because ".." is a hard link within the file
system to point to the physical parent. As soon as you start looking at
the file system tree that way round, you've lost the symbolic links,
which only work one way.
I'm guessing you're starting from a $PWD which contains symbolic links,
right? So you're going to need to prune that as a variable until you
find a directory with .shorten_folder_marker. I don't think there's a
way of doing this without a loop...
local dir=$PWD
while [[ $dir != / && ! -f $dir/.shorten_folder_marker ]]; do
dir=${dir:h}
done
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author