zsh compability for wmake/scripts/sysFunctions
Summary
This way of splitting strings does not seem to be ZSH compatible:
https://develop.openfoam.com/Development/openfoam/-/blame/master/wmake/scripts/sysFunctions#L270
leading to errors when searching for libraries (this came up for me when looking for scotch-system, where it looks for "libscotch.so .a" which obviously does not exist)
Steps to reproduce
export SCOTCH_VERSION=scotch-system in etc/config.sh/scotch
run wmake/scripts/have_scotch -debug-test
Example case
Note how string is not correctly split here: +findLibrary:58> ext=.a .so
source etc/bashrc
source wmake/scripts/sysFunctions
set -x && findLibrary -prefix="/usr" -name="libfoo"
+zsh:6> findLibrary '-prefix=/usr' '-name=libfoo'
+findLibrary:2> local prefixDir localDir searchDir searchName
+findLibrary:3> local file ext
+findLibrary:5> searchDir=true
+findLibrary:7> [ true '=' true ']'
+findLibrary:7> [ 2 -gt 0 ']'
+findLibrary:9> case -prefix=/usr (-prefix=*)
+findLibrary:11> prefixDir=/usr
+findLibrary:12> shift
+findLibrary:7> [ true '=' true ']'
+findLibrary:7> [ 1 -gt 0 ']'
+findLibrary:9> case -name=libfoo (-prefix=*)
+findLibrary:9> case -name=libfoo (-local=*)
+findLibrary:9> case -name=libfoo (-name=*)
+findLibrary:22> searchName=libfoo
+findLibrary:23> shift
+findLibrary:7> [ true '=' true ']'
+findLibrary:7> [ 0 -gt 0 ']'
+findLibrary:32> [ -n libfoo ']'
+findLibrary:37> : /usr
+findLibrary:38> [ -d /usr ']'
+findLibrary:41> set -- lib lib64 lib/x86_64-linux-gnu lib lib64 lib/x86_64-linux-gnu
+findLibrary:51> [ 0 -gt 1 ']'
+findLibrary:51> shift 3
+findLibrary:55> searchDir=lib
+findLibrary:57> [ -n lib ']'
+findLibrary:58> ext=
+findLibrary:60> file=/usr/lib/libfoo
+findLibrary:61> [ -f /usr/lib/libfoo ']'
+findLibrary:58> ext=.a .so
+findLibrary:60> file='/usr/lib/libfoo.a .so'
+findLibrary:61> [ -f '/usr/lib/libfoo.a .so' ']'
+findLibrary:55> searchDir=lib64
+findLibrary:57> [ -n lib64 ']'
+findLibrary:58> ext=
+findLibrary:60> file=/usr/lib64/libfoo
+findLibrary:61> [ -f /usr/lib64/libfoo ']'
+findLibrary:58> ext=.a .so
+findLibrary:60> file='/usr/lib64/libfoo.a .so'
+findLibrary:61> [ -f '/usr/lib64/libfoo.a .so' ']'
+findLibrary:55> searchDir=lib/x86_64-linux-gnu
+findLibrary:57> [ -n lib/x86_64-linux-gnu ']'
+findLibrary:58> ext=
+findLibrary:60> file=/usr/lib/x86_64-linux-gnu/libfoo
+findLibrary:61> [ -f /usr/lib/x86_64-linux-gnu/libfoo ']'
+findLibrary:58> ext=.a .so
+findLibrary:60> file='/usr/lib/x86_64-linux-gnu/libfoo.a .so'
+findLibrary:61> [ -f '/usr/lib/x86_64-linux-gnu/libfoo.a .so' ']'
+findLibrary:86> return 2
Environment information
- OpenFOAM version : v2112
- Operating system : Debian
- Zsh: zsh 5.7.1
Possible fixes
I see the following work arounds:
- Refactor string splitting
- If zsh is detected, set bash compability setting "setopt shwordsplit" (locally and reset after or globally in etc/bashrc), or
- Allwmake scripts which use non zsh compatible options are shebanged to /bin/bash instead of /bin/sh