*: Use xargs instead of while read one-line loops

This commit is contained in:
2025-05-27 17:00:35 +02:00
parent e9f05d5d08
commit 0c17ae8280
2 changed files with 4 additions and 13 deletions

View File

@@ -14,13 +14,8 @@ if [[ "$1" == "--new" ]]; then
grep path .gitmodules \ grep path .gitmodules \
| cut -d= -f2 \ | cut -d= -f2 \
| sed 's/^\s*//' \ | sed 's/^\s*//' \
| while read -r line; do | xargs -I'{}' find '{}' -maxdepth 0 -empty \
# keep only empty ones | xargs -L1 git submodule update --init --recursive --
find "$line" -maxdepth 0 -empty
done \
| while read -r line; do
git submodule update --init --recursive -- "$line"
done
else else
git submodule update --init --recursive git submodule update --init --recursive
fi fi

View File

@@ -7,15 +7,11 @@
# #
# pgrep --full "^($TERMINAL|tmux)( |$)" \ # pgrep --full "^($TERMINAL|tmux)( |$)" \
# | cut -d' ' -f1 \ # | cut -d' ' -f1 \
# | while read -r line; do # | xargs -n1 pgrep -P \
# pgrep -P "$line"
# done \
# NOTE: when using the full path not all shell instances are matched # NOTE: when using the full path not all shell instances are matched
pgrep "$(basename $SHELL)" \ pgrep "$(basename $SHELL)" \
| cut -d' ' -f1 \ | cut -d' ' -f1 \
| while read -r line; do | xargs pwdx 2>/dev/null \
pwdx "$line" 2>/dev/null
done \
| cut -d' ' -f2- \ | cut -d' ' -f2- \
| sort -ur | sort -ur