Karakas Online

7.1.1. Check number of parameters

As in every good script, a rudimentary parameter number check is the very first thing to do:

# Check arguments and issue a help statement, if wrong
#
if [ $# -eq 0 -o $# -gt 1 ]; then
  help 
  exit 1
elif [ $1 = "-h" -o $1 = "--help" ]; then
  help 
  exit 0
fi

If the number of parameters is not exactly 1, the output of the help() function is printed, which looks like this:

Usage: lyxtox [-h] [FILENAME_WITHOUT_.lyx_ENDING]
Creates HTML, PDF, RTF, TXT and PS output 
from a single LYX source.
Needs: lyx, runsed, sed, sedscr, jadetex.cfg, perl, openjade,
pdfjadetex, DocBook, TeX, LaTeX, thumbpdf, gzip, tar 
and all packages required from these.
See http://www.karakas-online.de/mySGML/ for a detailed 
description.
EXAMPLE
=======
If your file is myfile.lyx, then do
lyxtox myfile
go get a cup of coffee and be happy :-)
-h, --help    Display this help text
Last updated Mon Sep 24 01:19:25 CEST 2007 Permalink: http://www.karakas-online.de/mySGML/explain-check-number-of-parameters.html All contents © 2002-2007 Chris Karakas