[erlang-questions] os:cmd

Erik Søe Sørensen eriksoe@REDACTED
Mon May 21 04:16:43 CEST 2012


The behaviour and output of rsync, and indeed any command, may depend on
the environment - for instance the LANG and locale variable - and sometimes
also on whether the output goes directly to the console or not (see
isatty(3)).
Some C library functions behave differently depending on the locale, which
can be a bit surprising:

$ /usr/bin/printf "%f\n" "123.45"  # In the da_DK locale, decimal point is
","
123,450000

$ LANG=C /usr/bin/printf "%f\n" "123.45"
123.450000

$ type printf
printf is a shell builtin
$ printf "%f\n" "123.45"   # Uses the locale (da_DK) for parsing the number
bash: printf: 123.45: invalid number
0,000000

$ LANG=C printf "%f\n" "123.45"   # This ought to work, but doesn't
bash: printf: 123.45: invalid number
0,000000
$ export LANG=C ; printf "%f\n" "123.45"  # This works
123.450000

Sorting strings is another thing that may behave differently depending on
the locale.

2012/5/20 eigenfunction <emeka_1978@REDACTED>

> I am using rsync through os:cmd and rely on the console ouput from the
> rsync command to decide whether or not the operation was successulf or
> not, specially in the case where a file is missing on the remote end.
> What i found out is that the return value of os:cmd does not always
> equal the output of the rsync command run in the console.
> Therefore my question: Is it the normal behaviour?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120521/0aaad99b/attachment.htm>


More information about the erlang-questions mailing list