From: Peter Stephenson <p.stephenson@samsung.com>
To: <zsh-users@zsh.org>
Subject: Re: Symlinks in recursive glob
Date: Mon, 5 Nov 2018 09:52:17 +0000 [thread overview]
Message-ID: <1541411537.4795.1.camel@samsung.com> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2018-11-05 9:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181105001937epcas3p2ebd558b47eca5ed019b8762a91e96b96@epcas3p2.samsung.com>
2018-11-05 0:17 ` Dominik Ritter
2018-11-05 9:52 ` Peter Stephenson [this message]
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=1541411537.4795.1.camel@samsung.com \
--to=p.stephenson@samsung.com \
--cc=zsh-users@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).