Is there a shell (bash,zsh,??) that supports something like this?
git branch -D <feature1,feature2,feature3>
that would effectively make a transformation to:
for BRANCH in feature1 feature2 feature3; do git branch -D $BRANCH; done
On
##
# Run the given command (first args up to `--`)
# on each of the following args, one at a time.
# The name `map` is tongue-in-cheek.
#
# Usage: map [cmd] -- [args]
map() {
local -a cmd
local arg
while [[ $1 ]]; do
case "$1" in
--) break;;
esac
cmd+=( "$1" )
shift
done
shift
for arg; do
"${cmd[@]}" "$arg"
done
}
No, because this is not nearly as useful as it sounds. Most commands accept multiple arguments already, including
git branch -D:Commands that don't accept this typically have a good reason not to. For example,
convert "$file" output.jpghas an explicit output path, and naively looping over filenames would just overwrite the output.For these things,
zshhas short formforloops if it helps: