Last active
May 4, 2021 10:43
-
-
Save mvsde/1fefc8521abea9e60f4ab5815fe9067a to your computer and use it in GitHub Desktop.
Under-engineered multi-package management script. Uses only basic shell commands for compatibility with Docker alpine images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: | |
# -e: Exclude folders | |
# -p: Prioritize folders | |
# -c: Run this command | |
# execute.sh -e "folder1 folder2" -p "folder3 folder4" -c "command" | |
while getopts "e:p:c:" OPTION; do | |
case "$OPTION" in | |
e) EXCLUDE=$OPTARG;; | |
p) PRIORITY=$OPTARG;; | |
c) COMMAND=$OPTARG;; | |
esac | |
done | |
if [ "$EXCLUDE" ]; then | |
echo "Excluding folders $EXCLUDE." | |
echo "" | |
fi | |
if [ "$PRIORITY" ]; then | |
echo "Prioritizing folders $PRIORITY." | |
echo "" | |
fi | |
FOLDERS=$(ls packages) | |
for ITEM in $EXCLUDE; do | |
FOLDERS=$(echo $FOLDERS | sed "s/$ITEM//") | |
done | |
for ITEM in $PRIORITY; do | |
FOLDERS=$(echo $FOLDERS | sed "s/$ITEM//") | |
done | |
FOLDERS="$PRIORITY $FOLDERS" | |
echo $FOLDERS | xargs -n 1 sh -c "cd packages/\$0 && pwd && $COMMAND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment