You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most cases a command or application error should result in a non zero exit code to the shell. This does not happen when display.PrintErr is used since it swallows the error that is given back to cobra, resulting in a zero (success) exit code. This is both confusing and bad for scripting.
Another pitfall of display.PrintErr returning a nil error when given a (non-nil) error is that if misused in subfunctions rather than directly in the actually cobra RunE, it will often be used to direct logic (assuming there was no error but there was). I recently fixed several such misuses, so it would be good to somehow consider this in resolving the issue of cmd exit code.
The text was updated successfully, but these errors were encountered:
Most cases a command or application error should result in a non zero exit code to the shell. This does not happen when
display.PrintErr
is used since it swallows the error that is given back to cobra, resulting in a zero (success) exit code. This is both confusing and bad for scripting.Another pitfall of
display.PrintErr
returning a nil error when given a (non-nil) error is that if misused in subfunctions rather than directly in the actually cobraRunE
, it will often be used to direct logic (assuming there was no error but there was). I recently fixed several such misuses, so it would be good to somehow consider this in resolving the issue of cmd exit code.The text was updated successfully, but these errors were encountered: