Open Diogofornazari opened 2 years ago
According to netcalc -h
Global options:
-c Validate the IPv4/IPv6 address, no output if invalid
So, validating can be performed as:
# test -n "$(netcalc -c 2fe1:d200:0:0:0:c801:a68::)"
# echo $?
1
# test -n "$(netcalc -c 2fe1:d200:0:0:0:c801:a68:0)"
# echo $?
0
I agree a return code would be nice, but IIRC the long history of the netcalc code does not easily lend itself to adding that.
Hi Lonnie, Thanks for your attention. I agree with you when you mention the global options: "no output if invalid", the problem is that the validations are not working, cause in booth cases that you used, the ip address are right, the first one, that according to the answer, should be wrong, is only suppressed, not wrong.
About the output, is an easy problem to manage, unlike the validation.
Em qui., 23 de jun. de 2022 às 09:43, Lonnie Abelbeck < @.***> escreveu:
According to netcalc -h
Global options: -c Validate the IPv4/IPv6 address, no output if invalid
So, validating can be performed as:
test -n "$(netcalc -c 2fe1:d200:0:0:0:c801:a68::)"
echo $?
1
test -n "$(netcalc -c 2fe1:d200:0:0:0:c801:a68:0)"
echo $?
0
I agree a return code would be nice, but IIRC the long history of the netcalc code does not easily lend itself to adding that.
— Reply to this email directly, view it on GitHub https://github.com/troglobit/netcalc/issues/24#issuecomment-1164360480, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZXTXYBKXJGG2JJ64JO3WOLVQRLW7ANCNFSM5ZT6MK3A . You are receiving this because you authored the thread.Message ID: @.***>
I agree a return code would be nice, but IIRC the long history of the netcalc code does not easily lend itself to adding that.
Well we could change it but anyone scripting with netcalc would possibly start experiencing regressions after upgrading. Making sure the -c
option works is imo the least intrusive way forward.
Completely agree with You Mr. Wiberg. I've done some more tests and, even using the -c option, the validation doesn't work well when the 8 block is suppressed. Totally understand if it's not possible to make changes now, could be a big risk, while that, I'll try to find a way to treat it otherwise.
Thanks for your attention.
@Diogofornazari any help or input on improving -c
would be great, thank you for taking the time to report this!
Tool doesn't return error if IP is invalid ( you can put any value, invalid values (zxvf:mlpr9:...) and the return is always 0, like if it was okay); if block 8 is suppressed it doesn't show ip address and it doesn't show any error (abff:0:ed4a:123f:ddd:3e4f:104f::);
Examples
: netcalc zxvm:lçvd:: && echo Ok
: Ok
: netcalc 2fe1:d200:0:0:0:c801:a68:: 64
: echo $?
: 0