Re: Bug#295328: general: Help messages to stderr should be banned
"Francesco P. Lovergine" <frankie@debian.org> schrieb:
> On Tue, Feb 15, 2005 at 07:38:08AM -0600, John Hasler wrote:
>> Francesco P. Lovergine writes:
>> > It depends on programs, sometimes the same usage function is used for
>> > either --help or invalid options.
>>
>> Sure, but the output should still be directed correctly.
>
> Quite difficult if the function is the same. In both cases it uses stderr.
#!/bin/sh
usage(){
if [ "$1" = "STDERR" ]; then
EXITCODE=1
exec >&2;
else
EXITCODE=0
fi
echo "bla..."
exit $EXITCODE
}
case "$1" in
--help|-h|-help)
usage;;
--foo)
...
*)
usage STDERR;;
esac
Translation to Perl, Python, C, whatever, and to multiple arguments is
left to the reader as an afternoon exercise.
Regards, Frank
--
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer
Reply to: