kate.ward | 695ddde | 2008-06-26 22:22:26 +0000 | [diff] [blame] | 1 | #!/bin/sh |
kate.ward | 120b504 | 2008-06-27 08:58:03 +0000 | [diff] [blame^] | 2 | # |
| 3 | # Copyright 2008 Kate Ward. All Rights Reserved. |
| 4 | # Released under the LGPL (GNU Lesser General Public License) |
| 5 | # |
| 6 | # Author: kate.ward@forestent.com (Kate Ward) |
| 7 | # |
| 8 | # This script does the very simple job of echoing some text. If a '-d' (or |
| 9 | # '--debug') flag is given, additinal "debug" output is enabled. |
| 10 | # |
| 11 | # This script demonstrates the use of a boolean flag to enable custom |
| 12 | # functionality in a script. |
kate.ward | 695ddde | 2008-06-26 22:22:26 +0000 | [diff] [blame] | 13 | |
| 14 | # source shflags |
| 15 | . ../src/shflags |
| 16 | |
| 17 | debug() { [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ] && echo "DEBUG: $@" >&2; } |
| 18 | |
| 19 | # define flags |
| 20 | DEFINE_boolean 'debug' false 'enable debug mode' 'd' |
| 21 | |
| 22 | # parse the command-line |
| 23 | FLAGS "$@" || exit 1; shift ${FLAGS_ARGC} |
| 24 | |
| 25 | debug 'debug mode enabled' |
| 26 | echo 'something interesting' |