gissf1 / zram-hibernate

Allows dynamic swap changes to activate disk-based storage as swap for hibernation support when a system typically uses only zram swap during normal operation.
Apache License 2.0
35 stars 3 forks source link

script doesn't work with mawk #6

Closed ilobilo closed 2 months ago

ilobilo commented 9 months ago

mawk was preinstalled on my ubuntu 23.10 instead of gawk and this was the output after running the script with -d option

[8868] creating tmpfile...
[8868] lock acquired.
----- getMemInfo() ----------------------------------------
MemTotal=15748204
MemFree=1535368
MemAvailable=11507292
SwapTotal=15748092
SwapFree=15748092
----- getResumeInfo() ----------------------------------------
KERNEL_RESUME_RAW=/swapfile
KERNEL_RESUME_DEVICE=/swapfile
KERNEL_RESUME_UUID="19843ba4-f7a4-45c9-b094-be49e259bf86"
KERNEL_RESUME_CONF='/etc/zram-hibernate.conf'
----- getActiveSwapInfo() ----------------------------------------
ACTIVESWAP0_Filename=/dev/zram0
ACTIVESWAP0_Type=partition
ACTIVESWAP0_Size=15748092
ACTIVESWAP0_Used=0
ACTIVESWAP0_Priority=100
ACTIVESWAPS=1
----- getFstabSwapInfo() ----------------------------------------
FSTABSWAPS=0
----- getSwapInfo() ----------------------------------------
awk: line 15: syntax error at or near ,
awk: line 20: syntax error at or near else
awk: line 23: syntax error at or near else
awk: line 26: syntax error at or near return
awk: line 30: syntax error at or near [
---------------------------------------------

installing gawk fixed the issue

gissf1 commented 2 months ago

Thanks for the feedback!

I imagine there are many distros that don't use gawk by default, and this should help any users of those distros.

Anyone with similar errors as above should make sure that GNU awk (gawk) is installed.

I may modify the code eventually to be more portable to other awks (like mawk), but patches are also accepted :)