[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

EX_USAGE?



I have some trouble with the fact that an error in the invocation of
"main" is supposed to return EX_USAGE. Specifically
I have trouble thinking about a way to implement it in
a not too arcane way. 
(If there is an obvious solution, then please feel free to 
ignore this message)

1) Hooking into the error-mechanism isn't the problem,
  but after entry into "main", when user code is running,
  I can't think of a way to unhook the error handler again
  (We want a "meaningful" usage-related error message
  in the call to "main", but normal argc-error behaviour
  in case another procedure is called with the wrong number
  of arguments, right?)

2) Doing some fiddling with backtraces after the error
  situation doesn't look that good either, especially in
  the case of compiled scripts, which might not have
  much debugging info.

3) Normally I wouldn't ask about implementation-specific things
  like this. As I said: There might be a simple solution, and I'm just too
  stupid too see it, but:
  Is it really so helpful to have a distinct exit-code
  in this case? Don't have many scripts a variable number of
  arguments, anyway?


cheers,
felix