Hi Philipp, Coiby
On Thu, Aug 12, 2021 at 1:51 PM Kairui Song <kasong(a)redhat.com> wrote:
Updated file syntax with following command:
sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdump-lib.sh
sed -i -e 's/`\([^`]*\)`/\$(\1)/g' kdump-lib.sh
And manually updated [[ ... -a ... ]] and [[ ... -o ... ]] with && and
||.
Sorry about this commit message being too simplified,
About this changing to '[[ ]]', it's more versatile, safer, and
slightly faster than '[ ]'.
For example:
# here $a is empty:
$ [[ $a -ne 1 ]] && echo a
a
$ [ $a -ne 1 ] && echo a
bash: [: -ne: unary operator expected
[[]] handles many corner cases much better, and it's faster:
$ time for i in {1..100000}; do [ a = a ];done
real 0m2.068s
user 0m2.024s
sys 0m0.040s
$ time for i in {1..100000}; do [[ a = a ]];done
real 0m1.272s
user 0m1.242s
sys 0m0.028s
The only disadvantage is that [[]] is bash only, but kdump-lib.sh will
be bash only and only run in first kernel so this should be a good
idea.
I'll update the commit message.
--
Best Regards,
Kairui Song