Skip to content

Instantly share code, notes, and snippets.

@afirth
Created July 18, 2019 15:17
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 afirth/86d6437bf6a04f4e7dbe5370a1669554 to your computer and use it in GitHub Desktop.
Save afirth/86d6437bf6a04f4e7dbe5370a1669554 to your computer and use it in GitHub Desktop.
bash getopt get args getargs limoncelli
#!/bin/bash
MINITEMS=1
function usage { echo " Usage: $0 [-d] [-a author] [-c file.txt] [-h] dir1 [dir1 ...] -d debug, don't actual run command -a author name of the author -c copyright override default copyright file -h this help message " exit 1 }
# Set our defaults:
DEBUG=false DEBUGCMD= AUTHOR= COPYRIGHT=copyright.txt
# Process command-line arguments, possibly overriding defaults
args='getopt da:c:h $*'
if [ $? != 0 ] then usage fi
set -- $args
for i do
case "$i" in
-h) usage shift ;;
-a) AUTHOR="$2"; shift shift ;;
-c) COPYRIGHT="$2"; shift shift ;;
-d) DEBUG=true shift ;;
--) shift; break;;
esac
done
if $DEBUG ; then
echo DEBUG MODE ENABLED. DEBUGCMD=echo
fi
# Make sure we have the minimum number of items on the command line.
if $DEBUG ;
then echo ITEM COUNT = $# ; fi
if [ $# -lt "$MINITEMS" ]; then usage fi
# If the first option is special, capture it: # THEITEM="$1" ; shift # Clone that line for each item you want to gather.
# Make sure that you adjust the MINITEMS variable to suit your needs. # If you want to do something with each remaining item, do it here
: #for i in $* ; do # echo Looky! Looky! I got $i #done
if [ ! -z "$COPYRIGHT" ]; then
if $DEBUG ; then
echo Setting copyright to: $COPYRIGHT ;
fi
CRFLAG="-copyright $COPYRIGHT"
fi LABEL='date -u +%Y%m%d'
$DEBUGCMD mkisofs -D -l -J -r -L -f -P "$AUTHOR" -V $LABEL $CRFLAG $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment