Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 120239 - /lib/rcscripts/net.modules.d/ifconfig dependent on locale
Summary: /lib/rcscripts/net.modules.d/ifconfig dependent on locale
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: Lowest enhancement (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-24 16:10 UTC by Mark Dominik Bürkle
Modified: 2006-01-25 01:54 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Dominik Bürkle 2006-01-24 16:10:00 UTC
Hi,

after all, Gentoo is all about choice.
 So if anyone is keen enough to set his root- respectively boot-environment to some locale, then he should not get a bleedy nose (who didn't try that yet? ;-), e.g. with the newly introduced function ifconfig_is_ethernet:

somewhere ~ $ LC_ALL=de_DE /sbin/ifconfig eth0
eth0      Protokoll:Ethernet  Hardware Adresse 00:11:11:09:A3:36
... (my locales for fr_FR, jp_*, cn_* a be incomplete:)

that output would not match the newly-introduced function ifconfig_is_ethernet:

# Return 0 if the link is ethernet, otherwise 1.
ifconfig_is_ethernet() {
        ifconfig "$1" | grep -q "^$1[[:space:]]*Link encap:Ethernet[[:space:]]"
}

In my opinion, scripts or functions that do depend on a certain piece of text or format of output should set up a local environment for the programs producing the output that will be parsed, to ensure it will work everywhere (with all locales).
 Only one locale might be expected to be available everywhere: C (and maybe POSIX in the future), which I'm trying to use everywhere, where I have to parse some program's textual output, e.g.:

ifconfig_is_ethernet() {
        LC_ALL=C ifconfig "$1" | grep -q "^$1[[:space:]]*Link encap:Ethernet[[:space:]]"
}

Localized boot messages would hurt a little bit less then... ;-)

Kind regards,
Dominik
Comment 1 SpanKY gentoo-dev 2006-01-24 16:26:17 UTC
forcing LC_ALL globally would prevent localized boot messages (which we've started to do in trunk baselayout)

when code needs to grok the output of something, it should force LC_ALL=C
Comment 2 Mark Dominik Bürkle 2006-01-24 17:34:17 UTC
Yes,

LC_ALL=C my_command_producing_output | commands_using_output

was what I meant, not setting LC_ALL in global context.
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-01-25 01:54:14 UTC
If you look at the top of the ifconfig module you'll see that we alias ifconfig into LC_ALL=C /sbin/ifconfig, so all internal calls to ifconfig are prefixed with LC_ALL=C.