Skip to content

Instantly share code, notes, and snippets.

@alberto56
Created April 28, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alberto56/9946dbcbeed69ed111d5 to your computer and use it in GitHub Desktop.
Save alberto56/9946dbcbeed69ed111d5 to your computer and use it in GitHub Desktop.
Simple script starter
#!/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://me@git.example.com/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