@mwhudson,
your suggested change seems reasonable to me.
I don't love the use of 'eval', but it seems reasonably safe here.
Instead of quoting you could just reject argv[1] input if it
had characters other than [a-zA-z_.-] . Perhaps that makes
this more difficult.
Also, maybe you should try to 'setlocale(argv[1])' to check that
it is valid ? Ie, as it is right now if input is bogus then
the program will exit success and write bogus output.
@mwhudson,
your suggested change seems reasonable to me.
I don't love the use of 'eval', but it seems reasonably safe here.
Instead of quoting you could just reject argv[1] input if it
had characters other than [a-zA-z_.-] . Perhaps that makes
this more difficult.
Also, maybe you should try to 'setlocale( argv[1] )' to check that
it is valid ? Ie, as it is right now if input is bogus then
the program will exit success and write bogus output.
$ LC_ALL=asdf /tmp/my-test bogus ; echo $?
LC_ALL='bogus'
0