#758 Issue closed
: bash 3.x errors in recent changes¶
Labels: bug
, fixed / solved / done
jsmeix opened issue at 2016-01-21 13:11:¶
For current Git sources "make validate"
with GNU bash, version 3.1.17 results:
./usr/share/rear/output/ISO/Linux-i386/25_populate_efibootimg.sh: line 28: unexpected argument `(' to conditional binary operator ./usr/share/rear/output/ISO/Linux-i386/25_populate_efibootimg.sh: line 28: syntax error near `(s' ./usr/share/rear/output/ISO/Linux-i386/25_populate_efibootimg.sh: line 28: ` if [[ $(basename ${UEFI_BOOTLOADER}) =~ (shim.efi|elilo.efi) ]]; then ' ./usr/share/rear/rescue/GNU/Linux/31_network_devices.sh: line 59: unexpected argument `(' to conditional binary operator ./usr/share/rear/rescue/GNU/Linux/31_network_devices.sh: line 59: syntax error near `(^' ./usr/share/rear/rescue/GNU/Linux/31_network_devices.sh: line 59: ` if [ $DEVICE != "bonding_masters" ] && ! [[ $VIRTUAL_DEVICES =~ (^|[[:space:]])${DEVICE}($|[[:space:]]) ]]'
"git blame usr/share/rear/output/ISO/Linux-i386/25_populate_efibootimg.sh" shows:
33305d0f (Pavol Domin 2015-11-12 14:52:17 +0100 28) if [[ $(basename ${UEFI_BOOTLOADER}) =~ (shim.efi|elilo.efi) ]]; then
"git blame usr/share/rear/rescue/GNU/Linux/31_network_devices.sh" shows:
0a0afdcd (corin 2015-01-20 09:48:17 +0100 59) if [ $DEVICE != "bonding_masters" ] && ! [[ $VIRTUAL_DEVICES =~ (^|[[:space:]])${DEVICE}($|[[:space:]]) ]]
As far as I know it is still intended that rear works with bash 3.x.
If this is still true, the issue is a bug.
gdha commented at 2016-01-25 09:20:¶
@jsmeix good catch - will you correct it?
jsmeix commented at 2016-01-25 10:58:¶
I think I could correct it but not before FOSDEM.
I really must prepare for FOSDEM because
"You never get a second chance to make a good first impression".
;-)
If it needs to be fixed before FOSDEM,
perhaps @pavoldomin and/or @corin33
could do it?
jsmeix commented at 2016-02-09 14:59:¶
Hmpf!
It seems bash up to version 3.1 it works when quoting
of the extended regular expression like
# bash --version GNU bash, version 3.1.17(1)-release # UEFI_BOOTLOADER=/path/elilo.efi # [[ $(basename ${UEFI_BOOTLOADER}) =~ "(shim.efi|elilo.efi)" ]] && echo Y || echo N Y
while in bash 3.2 one must not use quoting:
# bash --version GNU bash, version 3.2.51(1)-release # UEFI_BOOTLOADER=/path/elilo.efi # [[ $(basename ${UEFI_BOOTLOADER}) =~ "(shim.efi|elilo.efi)" ]] && echo Y || echo N N
jsmeix commented at 2016-02-09 15:18:¶
I cannot fix the bash 3.x error in
rescue/GNU/Linux/31_network_devices.sh
because I do not sufficiently understand the meaning of the code.
Therefore I suggest @corin33 fixes his code in 31_network_devices.sh
jsmeix commented at 2016-02-10 15:37:¶
My
https://github.com/rear/rear/pull/765
hopefully fixes
the second bash 3.x issue (the one in 31_network_devices.sh).
Again:
I may not really properly have fixed the bash 3.x error in
rescue/GNU/Linux/31_network_devices.sh
because I do not sufficiently understand the meaning of the code.
Therefore I suggest again that @corin33 at least has a look
at that code in 31_network_devices.sh
jsmeix commented at 2016-02-11 12:43:¶
After the two above are fixed, a third one appeared
(one more in 31_network_devices.sh):
# bash --version GNU bash, version 3.1.17(1)-release # for f in $( find /usr/share/rear -name '*.sh' ) ; do bash -n $f ; done /usr/share/rear/rescue/GNU/Linux/31_network_devices.sh: line 162: unexpected argument `(' to conditional binary operator /usr/share/rear/rescue/GNU/Linux/31_network_devices.sh: line 162: syntax error near `(^' /usr/share/rear/rescue/GNU/Linux/31_network_devices.sh: line 162: ` [[ $VLANS_SET_UP =~ (^|[[:space:]])$IFACE($|[[:space:]]) ]] && return'
jsmeix commented at 2016-02-11 14:59:¶
With https://github.com/rear/rear/pull/767 all *.sh files in usr/share/rear pass the "bash -n" test with bash 3.x on SLE10:
# bash --version GNU bash, version 3.1.17(1)-release # for f in $( find /usr/share/rear -name '*.sh' ) ; do bash -n $f || echo $f failed ; done [no output] # bash -n /usr/sbin/rear || echo failed [no output]
jsmeix commented at 2016-02-11 15:55:¶
With https://github.com/rear/rear/issues/767 this issue should be fixed.
An addenum FYI:
I only liked to "just fix some" bash 3.x compliance issues
and what is the final result:
I became the one who is topmost to be blamed when something does not work in rescue/GNU/Linux/31_network_devices.sh regardless that I am not at all a networking expert:
$ git blame -wM usr/share/rear/rescue/GNU/Linux/31_network_devices.sh | cut -d ' ' -f2 | sort | uniq -c | sort -rn 187 (Johannes 61 (Schlomo 28 (corin 22 (Jeroen 19 (Dag 5 (jezzaaa 5 (Gratien 1 (Peter
For comparison how it had been before:
130 (corin 105 (Schlomo 22 (Dag 21 (Jeroen 18 (Gratien 7 (jezzaaa 1 (Peter
[Export of Github issue for rear/rear.]