On 7/11/19 1:29 AM, to...@tuxteam.de wrote:
On Wed, Jul 10, 2019 at 07:53:23PM -0700, David Christensen wrote:
On 7/10/19 10:39 AM, Martin McCormick wrote:
David Christensen <dpchr...@holgerdanske.com> writes:
[...]
Good points all around.
I would check for existence of the device (-e) and die if not present.
Perhaps even check whether the device is character special (-c): ISTR
the code tries to do some stty stuff which will fail otherwise.
I have always tried to do thorough error checking. In the past, I have
taken argument and/or state checking to the extreme. Currently, I tend
to do more moderate argument/ state checking and depend upon the error
checking code to deal with the advanced and/or corner cases -- e.g. "let
it crash", but capture all details required for a postmortem analysis.
OTOH it would preclude you to run the code (e.g. as a test) against a
FIFO: but then the failed attempt at stty should be non-fatal.
Perl, and its testing infrastructure, are especially amenable to
designing and coding for testability.
David