dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

template.sh (998B)


      1 #!/bin/sh
      2 # requirements: none
      3 
      4 version=0.1.0
      5 
      6 show_help() {
      7 	echo "usage: ${0##*/} [OPTIONS] COMMAND ..."
      8 	echo "short description here."
      9 	echo
     10 	echo "OPTIONS are one or more of the following:"
     11 	echo "   -h  show this message"
     12 	echo "   -v  show version and license information"
     13 	echo "   -V  show verbose information"
     14 	echo "   --  do not consider any following args as options"
     15 }
     16 
     17 show_version() {
     18 	echo "${0##*/} version $version"
     19 	echo "licensed under the ISC License"
     20 	echo "written by Anders Damsgaard, anders@adamsgaard.dk"
     21 	echo "https://src.adamsgaard.dk/dotfiles"
     22 }
     23 
     24 die() {
     25 	printf '%s: error: %s\n' "${0##*/}" "$1" >&2
     26 	exit 1
     27 }
     28 
     29 verbose=0
     30 while :; do
     31 	case "$1" in
     32 		-h)
     33 			show_help
     34 			exit 0;;
     35 		-v)
     36 			show_version
     37 			exit 0;;
     38 		-V)
     39 			verbose=1;;
     40 		--) # end all options
     41 			shift
     42 			break;;
     43 		-?*)
     44 			die "unknown option specified: $1";;
     45 		*)  # No more options
     46 			break
     47 	esac
     48 	shift
     49 done
     50 
     51 if [ $# -lt 1 ]; then
     52 	show_help
     53 	exit 1
     54 fi
     55 
     56 for arg in "$@"; do
     57 	# handle arguments
     58 done