# vim: ts=8:sw=4:sts=4:et:ft=zsh: # kate: byte-order-marker false; dynamic-word-wrap false; indent-mode normal; indent-pasted-text true; indent-width 4; keep-extra-spaces false; newline-at-eof true; remove-trailing-spaces all; replace-tabs true; replace-tabs-save true; show-tabs true; smart-home true; syntax Zsh; tab-width 8; word-wrap false; #----------------------------------------------------------------------- # #f1# List symlinks in detail (more detailed version of 'readlink -f' and 'whence -s') # # Usage: # # e.g.: a -> b -> c -> d .... # # sll a # # Note: limit for recursive symlinks on linux: # http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/namei.c?id=refs/heads/master#l808 # This limits recursive symlink follows to 8, while limiting # consecutive symlinks to 40. # # if given parameter with leading '=', lookup $PATH for parameter and resolve that # # sll =java # sll() { if [[ -z ${1} ]] then printf 'Usage: %s \n' "${0}" return 1 fi local file jumpd local curdir="${PWD}" declare -i lncnt RTN RTN=0 lncnt=0 for file in "${@}" ; do ls -l "${file}" || RTN=1 while [[ -h "$file" ]] ; do # remove trailing / if any file="${file%/}" # split $file in dirname jumpd="${file%/*}" # ... and basename file="${file##*/}" if [[ -d ${jumpd} ]] then builtin cd "${jumpd}" || RTN=1 fi file=$(readlink "$file") # remove trailing / if any file="${file%/}" # split $file in dirname jumpd="${file%/*}" # ... and basename file="${file##*/}" if [[ -d ${jumpd} ]] then builtin cd "${jumpd}" || RTN=1 fi ls -l "${PWD}/${file}" || RTN=1 lncnt=$(( lncnt +1 )) if (( ${lncnt} == 8 )) then print "limit for recursive symlinks reeached!" builtin cd "${curdir}" return 1 fi done builtin cd "${curdir}" done return ${RTN} }