mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
foreach
This commit is contained in:
16
local/bin/foreach
Normal file
16
local/bin/foreach
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# foreach <folder> <commands that should be run to each file>
|
||||
#
|
||||
# Source: https://github.com/mvdan/dotfiles/blob/master/.bin/foreach
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
for dir in $($cmd); do
|
||||
(
|
||||
echo "$dir"
|
||||
cd "$dir" || exit 1
|
||||
eval "$@" # allow multiple commands like "foo && bar"
|
||||
)
|
||||
done
|
||||
Reference in New Issue
Block a user