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

Re: symlink chain.



On Fri, 26 Dec 2014 20:50:03 -0800
Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> I just noticed that 'whence -s' very quietly 'finishes' a chain of 
> links, and shows you the final target.  'ls' OTOH only ever shows you 
> the first link in a chain. It gets me wanting some way of showing an 
> entire chain of links where that applies.  Can it be done?

showlinkchain () {
  zmodload -F zsh/stat b:zstat
  local args
  while [[ -h $1 ]]
  do
    zstat -A args +link $1
    if [[ -n $args[1] ]]
    then
      print -r - $args[1]
      set -- $args[1]
    else
      break
    fi
  done
}


pws



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