Modify

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#23951 closed defect (fixed)

Startup Shell Script Warning

Reported by: pch13@… Owned by: team
Priority: normal Milestone: 24.10
Component: Core Version: tested
Keywords: Linux Cc: sebastic

Description

When I start JOSM in a terminal I see this error/warning message:

/usr/bin/josm: Zeile 61: [: : Ganzzahliger Ausdruck erwartet.

The script in line 61 wants an integer but got something different. I run the code there manually:

$ free --mega
              gesamt      belegt       frei     gemeinsam    Zwischen   verfügbar
Speicher:       16643        8531         484         882        7627        6885

It might work like this:

$ LANG=C free --mega
              total        used        free      shared  buff/cache   available
Mem:          16643        8533         488         876        7621        6890

Running JOSM/1.5 (19230 de) Linux Ubuntu 20.04.6 LTS

Attachments (0)

Change History (4)

comment:1 by skyper, 5 months ago

Cc: sebastic added
Keywords: Linux added
Version: tested

See r19215.
So following does only work with system language set to English or C.

# If there is more than 8G ram, we can use up to 75% of the memory while still leaving 2G for other things.
if [ "$(free --mega | grep '^Mem:' | awk '{print $2}')" -gt 8192 ];

Maybe, reading directly from /proc like cat /proc/meminfo is system language independent.

Last edited 5 months ago by skyper (previous) (diff)

comment:2 by sebastic, 5 months ago

This should be more reliable as mentioned in #23837:

if [ "$(awk '/^MemTotal:/ {print int($2 / 1024)}' /proc/meminfo)" -gt 8192 ]; then

i.e.:

$ LC_ALL=de_DE.UTF-8 LANG=de_DE.UTF-8 free --mega | grep '^Mem:' | awk '{print $2}'
$ LC_ALL=de_DE.UTF-8 LANG=de_DE.UTF-8 free --mega | grep '^Speicher:' | awk '{print $2}'
67021
$ LC_ALL=de_DE.UTF-8 LANG=de_DE.UTF-8 awk '/^MemTotal:/ {print int($2 / 1024)}' /proc/meminfo 
63916

Or set the locale in the environment for free(1):

if [ "$(LC_ALL=C LANG=C free --mega | grep '^Mem:' | awk '{print $2}')" -gt 8192 ];
Last edited 5 months ago by sebastic (previous) (diff)

comment:3 by taylor.smock, 5 months ago

Resolution: fixed
Status: newclosed

In 19234/josm:

Fix #23951: Fix free in startup linux scripts when it is in a localized environment

comment:4 by taylor.smock, 5 months ago

Milestone: 24.10

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.