[dev] Re: [dev] Re: [dev] Re: [dev] [dev] Usage, -h, --help, help, synopsis, …

From: Suraj Kurapati <sunaku_AT_gmail.com>
Date: Sat, 21 Aug 2010 11:47:37 -0700

On Sat, Aug 21, 2010 at 4:22 AM, yy <yiyu.jgl_AT_gmail.com> wrote:
> 2010/8/19 Suraj Kurapati <sunaku_AT_gmail.com>:
>> On Tue, Aug 17, 2010 at 7:54 PM, Suraj Kurapati <sunaku_AT_gmail.com> wrote:
>> #!/bin/sh
>> # your program description & usage documentation here
>> # nicely formatted and beautified to fit 80 columns
>> # NOTE: the blank line below is the end of the file comment header
>>
>>  sed -n '2,/^$/s/^# \?//p' "$0" # show this file's comment header
>
> I find this solution really convoluted. Why not using echo? You can
> use an USAGE variable, or even a here-document and cat<< if you feel
> like it.

I like to put documentation at the head of a file because that's only
part anyone will read before deciding if it's worth spending their
time to delve into the rest of the shell script. Also, I don't like
messing up my program's indentation because I have to emit a big block
of text in it:

if ...; then # ugly!
  cat <<EOF
your documentation here
EOF
fi

> And btw, it would probably be a good idea to redirect the
> help message to stderr.

Good idea.
Received on Sat Aug 21 2010 - 20:47:37 CEST

This archive was generated by hypermail 2.2.0 : Sat Aug 21 2010 - 21:00:01 CEST