zsh-users
 help / color / mirror / code / Atom feed
* How to resolve a symlink's to its non-existing destination?
@ 2023-04-29 18:06 Marlon Richert
  2023-04-29 18:17 ` Roman Perepelitsa
  0 siblings, 1 reply; 2+ messages in thread
From: Marlon Richert @ 2023-04-29 18:06 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

When I use :a, :A or :P on a symlink whose destination does not exist, I do
not get the output I'm expecting:

% touch foo
% ln -s foo bar
% print bar(:P)
/private/var/folders/hk/lcsr76092ygbtc8y1fryg7jh0000gn/T/tmp.ir6Iuz7K/foo
% rm foo
% print bar(:P)
/private/var/folders/hk/lcsr76092ygbtc8y1fryg7jh0000gn/T/tmp.ir6Iuz7K/bar
%

How can I consistently resolve a symlink's destination, regardless of
whether it exists?

I know I can use readlink for this, but is there any way to do this with
Zsh?

[-- Attachment #2: Type: text/html, Size: 1142 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to resolve a symlink's to its non-existing destination?
  2023-04-29 18:06 How to resolve a symlink's to its non-existing destination? Marlon Richert
@ 2023-04-29 18:17 ` Roman Perepelitsa
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Perepelitsa @ 2023-04-29 18:17 UTC (permalink / raw)
  To: Marlon Richert; +Cc: Zsh Users

On Sat, Apr 29, 2023 at 8:07 PM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> How can I consistently resolve a symlink's destination, regardless of whether it exists?

You can read the target of a link with zstat:

    % zstat +link -LA link -- bar && typeset -p link
    typeset -a link=( foo )

You might have to do this recursively.

Roman.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-29 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-29 18:06 How to resolve a symlink's to its non-existing destination? Marlon Richert
2023-04-29 18:17 ` Roman Perepelitsa

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