zsh-users
 help / color / mirror / code / Atom feed
* globbing on symlink target
@ 2018-02-28 18:42 Eitan Adler
  2018-02-28 19:31 ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Eitan Adler @ 2018-02-28 18:42 UTC (permalink / raw)
  To: zsh-users

Is it possible to glob on a symlink target rather than the symlink
name. For example I have several symlinks that *point to* filenames of
the form ABX.rb but themselves have no pattern to match on. I could
write a loop and use readlink but would prefer to use glob syntax for
interactive use.

-- 
Eitan Adler


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

* Re: globbing on symlink target
  2018-02-28 18:42 globbing on symlink target Eitan Adler
@ 2018-02-28 19:31 ` Mikael Magnusson
  2018-02-28 20:59   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2018-02-28 19:31 UTC (permalink / raw)
  To: Eitan Adler; +Cc: Zsh Users

On Wed, Feb 28, 2018 at 7:42 PM, Eitan Adler <lists@eitanadler.com> wrote:
> Is it possible to glob on a symlink target rather than the symlink
> name. For example I have several symlinks that *point to* filenames of
> the form ABX.rb but themselves have no pattern to match on. I could
> write a loop and use readlink but would prefer to use glob syntax for
> interactive use.

% ls -l *(@)
lrwxrwxrwx 1 mikaelh users 3 Feb 28 16:50 broken -> foo
lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 broken2 -> bar
lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 hello -> foo
% echo *(e*'local -A foo; zstat -LH foo $REPLY; [[ $foo[link] == foo ]]'*)
broken hello

It is arguable if this is interactive use syntax. You could write a
wrapper function but then you need to quote foo (again).

-- 
Mikael Magnusson


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

* Re: globbing on symlink target
  2018-02-28 19:31 ` Mikael Magnusson
@ 2018-02-28 20:59   ` Bart Schaefer
  2018-02-28 22:19     ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2018-02-28 20:59 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Eitan Adler, Zsh Users

On Wed, Feb 28, 2018 at 11:31 AM, Mikael Magnusson <mikachu@gmail.com> wrote:
> On Wed, Feb 28, 2018 at 7:42 PM, Eitan Adler <lists@eitanadler.com> wrote:
>> Is it possible to glob on a symlink target rather than the symlink
>> name.
>
> % ls -l *(@)
> lrwxrwxrwx 1 mikaelh users 3 Feb 28 16:50 broken -> foo
> lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 broken2 -> bar
> lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 hello -> foo
> % echo *(e*'local -A foo; zstat -LH foo $REPLY; [[ $foo[link] == foo ]]'*)
> broken hello

Should be easier than that -- using Eitan example of files with a
".rb" extension:

% ls *(@e^'[[ $REPLY:P = *.rb ]]'^)


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

* Re: globbing on symlink target
  2018-02-28 20:59   ` Bart Schaefer
@ 2018-02-28 22:19     ` Mikael Magnusson
  0 siblings, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2018-02-28 22:19 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Eitan Adler, Zsh Users

On Wed, Feb 28, 2018 at 9:59 PM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Wed, Feb 28, 2018 at 11:31 AM, Mikael Magnusson <mikachu@gmail.com> wrote:
>> On Wed, Feb 28, 2018 at 7:42 PM, Eitan Adler <lists@eitanadler.com> wrote:
>>> Is it possible to glob on a symlink target rather than the symlink
>>> name.
>>
>> % ls -l *(@)
>> lrwxrwxrwx 1 mikaelh users 3 Feb 28 16:50 broken -> foo
>> lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 broken2 -> bar
>> lrwxrwxrwx 1 mikaelh users 3 Feb 28 20:27 hello -> foo
>> % echo *(e*'local -A foo; zstat -LH foo $REPLY; [[ $foo[link] == foo ]]'*)
>> broken hello
>
> Should be easier than that -- using Eitan example of files with a
> ".rb" extension:
>
> % ls *(@e^'[[ $REPLY:P = *.rb ]]'^)

Ah, that is indeed easier. I think you can't differentiate relative or
absolute symlinks with this method though, if you happen to care about
that.

-- 
Mikael Magnusson


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

end of thread, other threads:[~2018-02-28 22:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 18:42 globbing on symlink target Eitan Adler
2018-02-28 19:31 ` Mikael Magnusson
2018-02-28 20:59   ` Bart Schaefer
2018-02-28 22:19     ` Mikael Magnusson

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