cardano-community / guild-operators

Artifacts and scripts created by Guild operators
https://cardano-community.github.io/guild-operators
MIT License
354 stars 177 forks source link

Locale Issue - Incorrect calculation and formatting in gLiveMode script on Centos OS 8. #569

Closed krzo93 closed 3 years ago

krzo93 commented 3 years ago

Describe the bug When running gLiveMode script on Centos OS 8, I am getting some printf errors on the display.

To Reproduce Steps to reproduce the behavior:

  1. Run gLiveMode.sh on Centos OS 8
  2. See error

Expected behavior Correct calculation of tips, density etc..

Screenshots Screenshot_20201028_214858

Version:

Additional context This is the lines that are shown in the screenshot above.

./gLiveView.sh: line 746: printf: 17.91296296296296296200: invalid number 746: epoch_items=$(( $(printf %.0f "${epoch_progress}") * granularity / 100 ))

./gLiveView.sh: line 741: printf: 17.91296296296296296200: invalid number 741: epoch_progress_1dec=$(printf "%2.1f" "${epoch_progress}")

./gLiveView.sh: line 513: printf: 4.896071809053199e-2: invalid number 513: density=$(printf "%3.3e" "${density}"| cut -d 'e' -f1)

rdlrt commented 3 years ago

I suppose the scripts may not have been tested for other locales, but just to be 100% - could you check and confirm the output of the below:

printf "%3.3e\n" "4.896071809053199e-2";locale

LC_ALL='C.UTF-8'; printf "%3.3e\n" "4.896071809053199e-2"
krzo93 commented 3 years ago

Hi @rdlrt

First time I've got invalid number again, after the second command it seems to look fine I think.

Command: printf "%3.3e\n" "4.896071809053199e-2"; Output: 4.896e-02

Any idea what this is happening? Just locale related issue?

Thanks

rdlrt commented 3 years ago

Any idea what this is happening? Just locale related issue?

Yeah - as I mentioned , most of the testing would've occurred using en locales. In your case, I am guessing your locale recognises numbers as comma (v/s decimal). Thus, causing trouble.

A quick fix for you would be to add the below to your $CNODE_HOME/scripts/env file (under User Variables section):

export LC_ALL='C.UTF-8'

So, something like this: image

I would think that should make guild tools use C.UTF8 for locale values instead of your system default, thereby not hitting you mentioned

krzo93 commented 3 years ago

Hi @rdlrt

Yeah, I've changed my system default now to C.UTF-8.

Thanks