show
- # The function "show" first creates an empty array variable "show", then
- # assigns to it the glob expansion (toggled on by `~') of its arguments
- # ($*). The alias inserts "noglob" so that any glob pattern I give on
- # the command line has its expansion delayed until $~* in the function.
- # In conjunction with CSH_NULL_GLOB, when the glob fails, this produces
- # zsh: no match
- # -after- emptying the previous value of $show. I've considered putting
- # "setopt localoptions cshnullglob" in the show() body, but I always have
- # it set anyway. In any case, the intent is that $show is non-empty only
- # when the glob matches something.
- #
- # (This does conflict with the MH "show" command, but then, I don't use MH.)
- #
- # An example of when I use this is when patching zsh sources. Typically I
- # apply the patches, then check for which files changed and which patches
- # failed:
- #
- # zsh% ls **/*.{orig,rej}
- #
- # And finally, if there were no errors, remove all the .orig and .rej files:
- #
- # zsh% rm -f **/*.{orig,rej}
- #
- # With "show", rather than repeat the recursive glob, I can just do:
- #
- # zsh% show **/*.{orig,rej}
- # zsh% rm -f $show
- function show() { show=(); show=( $~* ); print -rc $show }
- alias show "noglob show"