fix: resolve critical issues in x-clean-vendordirs, x-foreach, x-ip

x-clean-vendordirs: remove broken msgr dependency (not sourced),
add set -euo pipefail. x-foreach: replace eval on command args with
direct "$@" execution, add usage guard. x-ip: add set -euo pipefail,
curl dependency check, and silent-fail flag.
This commit is contained in:
2026-02-05 20:52:15 +02:00
parent fc8db1f5b5
commit efd9eebc85
3 changed files with 33 additions and 13 deletions

View File

@@ -1,18 +1,26 @@
#!/usr/bin/env bash
#
# foreach <folder> <commands that should be run to each file>
# foreach "ls -d */" "git status" # run git status in each folder
# Run a command in each directory matching a pattern.
#
# Usage: x-foreach <listing-command> <command> [args...]
# x-foreach "ls -d */" "git status"
#
# Source: https://github.com/mvdan/dotfiles/blob/master/.bin/foreach
cmd=$1
set -euo pipefail
if [ $# -lt 2 ]; then
echo "Usage: $0 <listing-command> <command> [args...]"
exit 1
fi
listing=$1
shift
for dir in $($cmd); do
for dir in $(eval "$listing"); do
(
echo "$dir"
cd "$dir" || exit 1
# shellcheck disable=SC2294,SC2034
eval "$@" # allow multiple commands like "foo && bar"
"$@"
)
done