#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/dvd original-function () { echo $funcstack[3] } print-ext-error-msg () { local ext=$1 local fun=${2:-$(original-function)} echo "$fun: no support for extension: .$ext" >&2 } check-files () { local error=0 for f in $files; do if [[ ! -f $f && ! -d $f ]]; then no-file-msg $f $(original-function) error=1 fi done (( error )) && return 1 return 0 } no-file-msg () { local file=$1 local fun=${2:-$(original-function)} echo "$fun: no such file: $file" >&2 } wrong-number-of-arguments-message () { local got=$1 local wants=$2 local fun=$(original-function) echo "${fun}: wrong number of arguments - got ${got}, wants ${wants}" >&2 } not-in-x-msg () { local fun=$(original-function) [[ -s $fun ]] && fun="${fun}: " # no fun if used from script echo "${fun}you are not in X" >&2 } all-processes-terminated-msg () { local fun=$(original-function) echo "$fun: all processes terminated" }