abandonware/wireless-tools

ifconfig does not work properly on some locale

squareboxjp opened this issue · 2 comments

When LANG has been set to fr_FR.UTF-8, stdout of ifconfig is as following.

wlan0 Link encap:Ethernet HWaddr 34:76:c5:5d:65:e3
inet adr:192.168.10.1 Bcast:192.168.10.255 Masque :255.255.255.0
adr inet6: fe80::6b63:a10d:d185:85c0/64 Scope:Lien
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21287 errors:0 dropped:13 overruns:0 frame:0
TX packets:131 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:0 (0.0 B) TX bytes:40210 (39.2 KiB)

In this case, subnet mask value will not be shown.
Because regex does never match the word 'Mask'.

if ((match = block.match(/Mask:\s*([^\s]+)/))) {
parsed.ipv4_subnet_mask = match[1];
}

This issue will happen on other locale like ja_JP.UTF8.

Adding locale support would be a nice feature, although it is definitely not a quick feature addition. There will need to be a RegexFactory that provides the regular expressions to each of the commands, and then derived instances (such as FrenchRegexFactory) that modify the expressions accordingly. I accept pull requests if you are interested in contributing.

Hello,

I would rather ensure that each command called by the package is exec'ed with LANG=C to ensure that the output parsing only needs to be done in english.