blob: ed552ef8aee52d8c001f53cdb8bf8bc6ea8f88f0 [file] [log] [blame]
kate.ward695ddde2008-06-26 22:22:26 +00001#!/bin/sh
kate.ward120b5042008-06-27 08:58:03 +00002#
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.ward695ddde2008-06-26 22:22:26 +000013
14# source shflags
15. ../src/shflags
16
17debug() { [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ] && echo "DEBUG: $@" >&2; }
18
19# define flags
20DEFINE_boolean 'debug' false 'enable debug mode' 'd'
21
22# parse the command-line
23FLAGS "$@" || exit 1; shift ${FLAGS_ARGC}
24
25debug 'debug mode enabled'
26echo 'something interesting'