Created
February 17, 2021 16:19
-
-
Save 4brunu/9b15bdb0b8f850e61d16b800130182eb to your computer and use it in GitHub Desktop.
This file contains 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
#! /usr/bin/env bash | |
while [[ $# -gt 1 ]] | |
do | |
key="$1" | |
case $key in | |
-p|--prefix) | |
IFS=';' read -ra PREFIX <<< "$2" | |
shift # past argument | |
;; | |
-s|--source) | |
IFS=';' read -ra SOURCE <<< "$2" | |
shift # past argument | |
;; | |
-d|--destination) | |
IFS=';' read -ra DESTINATION <<< "$2" | |
shift # past argument | |
;; | |
*) | |
# unknown option | |
;; | |
esac | |
shift # past argument or value | |
done | |
echo PREFIX = "${PREFIX}" | |
echo SOURCE = "${SOURCE}" | |
echo DESTINATION = "${DESTINATION}" | |
if [ ! "$PREFIX" ] || [ ! "$SOURCE" ] || [ ! "$DESTINATION" ] | |
then | |
echo "Usage: sh mirror.sh --prefix <cpp> --source <temp-generated-src/cpp> --destination <generated-src/cpp>" | |
exit 1 | |
fi | |
mkdir -p "$DESTINATION" | |
rsync -a --delete --checksum --itemize-changes "$SOURCE"/ "$DESTINATION" | sed "s/^/[$PREFIX]/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment