Created
April 28, 2015 14:10
-
-
Save alberto56/9946dbcbeed69ed111d5 to your computer and use it in GitHub Desktop.
Simple script starter
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/bash | |
if [ "$#" -eq "0" ] | |
then | |
echo "Fetches a branch for a given repo, and then adds a link to it on the index" | |
echo "of the given repo." | |
echo "" | |
echo "Usage:" | |
echo "" | |
echo "./fetch-branch.sh -d=/path/to/repo --r=ssh://[email protected]/project --b=master" | |
else | |
while getopts ":d:r:b:" opt; do | |
case $opt in | |
d) dir="$OPTARG" | |
;; | |
r) repo="$OPTARG" | |
;; | |
b) branch="$OPTARG" | |
;; | |
\?) echo "Invalid option -$OPTARG" >&2 | |
;; | |
esac | |
done | |
if [ -z "$dir" ]; then echo "The argument -d is not set. Execute with no arguments for usage."; exit 1; fi | |
if [ -z "$repo" ]; then echo "The argument -r is not set. Execute with no arguments for usage."; exit 1; fi | |
if [ -z "$branch" ]; then echo "The argument -b is not set. Execute with no arguments for usage."; exit 1; fi | |
printf "Argument d is %s\n" "$d" | |
printf "Argument r is %s\n" "$r" | |
printf "Argument b is %s\n" "$b" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment