Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return codes are always zero #5

Open
m-fonseca opened this issue Aug 23, 2019 · 2 comments
Open

return codes are always zero #5

m-fonseca opened this issue Aug 23, 2019 · 2 comments

Comments

@m-fonseca
Copy link

: netmask --version
netmask, version 2.4.4
: netmask asdf
netmask: parse error "
: echo $?
0

All errors have a zero return code. This makes it less then ideal for scripting.

thus

: netmask 192.168.1.255 && echo "valid address" 
  192.168.1.255/32
valid address

&

: netmask 192.168.1.256 && echo "valid address" 
netmask: parse error "192.168.1.256": Invalid argument
valid address

are both 'valid addresses'

@tlby
Copy link
Owner

tlby commented Aug 23, 2019

This is a good argument for promoting this warning to an error. Thank you for pointing it out.

@tlby
Copy link
Owner

tlby commented Oct 3, 2019

I will point out that if the goal is to use this tool purely to do address validation, I'd recommend using a different strategy. perhaps something like:

: perl -MSocket -le 'exit(not Socket::inet_pton AF_INET(), $ARGV[0])' 192.168.1.255 && echo "valid address"
valid address

vs.

: perl -MSocket -le 'exit(not Socket::inet_pton AF_INET(), $ARGV[0])' 192.168.1.256 && echo "valid address"

could be used for that purpose.

Nevertheless, this tool should consider bad input a fatal rather than a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants