commit | f657a816b9074f5bf2b3d300d93266269c1f05a5 | [log] [tgz] |
---|---|---|
author | guillaume.lambert <guillaume.lambert@orange.com> | Tue Dec 07 20:21:17 2021 +0100 |
committer | guillaume.lambert <guillaume.lambert@orange.com> | Wed Dec 08 13:59:00 2021 +0100 |
tree | f639250c0375d2e8a7017e694342e38809155530 | |
parent | 370c6dc33e55bfee7b3b79bcc21481b02a3f1e24 [diff] [blame] |
[COMMON] Fix "local var=XX" bashisms Variable attribute 'local' is not POSIX but is LSB supported. It is available in other shells such as ash or dash. And in ksh, local is the default scope of functions vaiables. Though, the syntax "local var=XX" is only supported and found in bash. Sadly, this is not detected by checkbashims. - fix "local var=XX" bashisms - add a manual command in tox.ini to detect them in the CI https://wiki.ubuntu.com/DashAsBinSh#local https://wiki.ubuntu.com/DashAsBinSh#declare_or_typeset https://stackoverflow.com/questions/12000949/scope-of-variables-in-ksh Issue-ID: OOM-2643 Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com> Change-Id: Iff26e50cd352eeb760d923a4740a6f92184fe0f2
diff --git a/kubernetes/config/prepull_docker.sh b/kubernetes/config/prepull_docker.sh index 596ace6..bfd679b 100755 --- a/kubernetes/config/prepull_docker.sh +++ b/kubernetes/config/prepull_docker.sh
@@ -27,8 +27,15 @@ #calling syntax: parse_yaml <yaml_file_name> parse_yaml () { - local prefix=$2 - local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') + local prefix + prefix=$2 + local s + s='[[:space:]]*' + local w + w='[a-zA-Z0-9_]*' + local fs + fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |