Add check-dummy.sh script
Added a new bash script that always returns OK. The script has usage instructions and exit codes. It also uses getopt to parse arguments. Significant changes: - Added check-dummy.sh - Script always returns OK - Usage instructions added - Exit codes defined - Getopt used for argument parsing
This commit is contained in:
parent
41082ce029
commit
30369488f8
61
check-dummy.sh
Normal file
61
check-dummy.sh
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
#/
|
||||||
|
#/ Usage:
|
||||||
|
#/ check-dummy.sh
|
||||||
|
#/
|
||||||
|
#/ Does not check anything. Always gives OK!
|
||||||
|
#/
|
||||||
|
#/
|
||||||
|
#/ Exit Codes:
|
||||||
|
#/ 0 Everything OK
|
||||||
|
#/
|
||||||
|
|
||||||
|
Usage() {
|
||||||
|
grep '^#/' "${script_dir}/${script_name}" | sed 's/^#\/\w*//'
|
||||||
|
}
|
||||||
|
|
||||||
|
GetOptions() {
|
||||||
|
# https://stackoverflow.com/a/29754866
|
||||||
|
OPTIONS=''
|
||||||
|
LONGOPTS=''
|
||||||
|
|
||||||
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
|
# -temporarily store output to be able to check for errors
|
||||||
|
# -activate quoting/enhanced mode (e.g. by writing out “--options”)
|
||||||
|
# -pass arguments only via -- "$@" to separate them correctly
|
||||||
|
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
|
||||||
|
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||||
|
# e.g. return value is 1
|
||||||
|
# then getopt has complained about wrong arguments to stdout
|
||||||
|
Usage
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# read getopt's output this way to handle the quoting right:
|
||||||
|
eval set -- "$PARSED"
|
||||||
|
|
||||||
|
# now enjoy the options in order and nicely split until we see --
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "URL UNKNOWN - ${1} is not a valid parameter"
|
||||||
|
exit 3
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z ${1+x} ]; then
|
||||||
|
echo "URL UNKNOWN - url not given"
|
||||||
|
exit 3
|
||||||
|
else
|
||||||
|
url=${1}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo "DUMMY OK"
|
||||||
|
exit 0
|
Loading…
x
Reference in New Issue
Block a user