Guest User

Untitled

a guest
Oct 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. announce () {
  4. [[ $verbose -eq 1 ]] && echo "$@"
  5. [[ ! -z $logfile ]] && echo "$@" >> "$logfile"
  6. }
  7.  
  8.  
  9. usage()
  10. {
  11. cat <<EOF
  12. Usage: $0 [-v] [-l file]
  13. -v - verbose
  14. -l - logfile
  15. EOF
  16. }
  17.  
  18.  
  19. main()
  20. {
  21. while getopts "l:v" c; do
  22. case "$c" in
  23. v) verbose=1;;
  24. l) logfile="$OPTARG";;
  25. ?*) usage && exit 1;;
  26. esac
  27. done
  28.  
  29. announce "Running:"
  30. # ...
  31. }
  32. main "$@"
Add Comment
Please, Sign In to add comment