项目作者: kakwa

项目描述 :
just a simple script skeleton initializer
高级语言: Shell
项目地址: git://github.com/kakwa/mk-sh-skel.git
创建时间: 2013-02-01T08:37:57Z
项目社区:https://github.com/kakwa/mk-sh-skel

开源协议:Other

下载


mk-sh-skel

just a simple script skeleton initializer

License

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

Installation

Quick and dirty:

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

Cleaner:

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

Usage

It’s quite simple:

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

Skeleton output

It generates a basic skeleton with help and getopts

  1. #!/bin/sh
  2. help(){
  3. cat <<EOF
  4. usage: `basename $0` <args>
  5. <description>
  6. arguments:
  7. <options>
  8. EOF
  9. exit 1
  10. }
  11. while getopts ":hn:" opt; do
  12. case $opt in
  13. h) help;;
  14. n) NAME="$OPTARG";;
  15. \?) echo "Invalid option: -$OPTARG" >&2 ;help; exit 1 ;;
  16. :) echo "Option -$OPTARG requires an argument." >&2; help; exit 1;;
  17. esac
  18. done