Skip to content

kakwa/mk-sh-skel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mk-sh-skel

just a simple script skeleton initializer

License

mk-sh-skel is released under the MIT Public License

Installation

Quick and dirty:

rm -f /usr/local/bin/mksh-skel
curl https://raw.githubusercontent.com/kakwa/mk-sh-skel/master/mksh-skel \
-o /usr/local/bin/mksh-skel
chmod 755 /usr/local/bin/mksh-skel
#end

Cleaner:

# after recovering the sources
make install # PREFIX=/usr/local/ DESTDIR=./buildroot/

Usage

It's quite simple:

mksh-skel -n <path/to/new/script>

Skeleton output

It generates a basic skeleton with help and getopts

#!/bin/sh

help(){
  cat <<EOF
usage: `basename $0` <args>

<description>

arguments:
  <options>
EOF
  exit 1
}

while getopts ":hn:" opt; do
  case $opt in
    h)  help;;
    n)  NAME="$OPTARG";;
    \?) echo "Invalid option: -$OPTARG" >&2 ;help; exit 1 ;;
    :)  echo "Option -$OPTARG requires an argument." >&2; help; exit 1;;
  esac
done