On Sat, Aug 21, 2010 at 4:22 AM, yy <yiyu....@gmail.com> wrote:
> 2010/8/19 Suraj Kurapati <sun...@gmail.com>:
>> On Tue, Aug 17, 2010 at 7:54 PM, Suraj Kurapati <sun...@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.

Reply via email to