From d5e82f072e9fbc77d723677217b3c55d2f299aa5 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 22 Nov 2022 18:03:16 +0100 Subject: [PATCH] CONFIG: handle string splitting [zsh] (#2640) --- wmake/scripts/sysFunctions | 42 ++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/wmake/scripts/sysFunctions b/wmake/scripts/sysFunctions index d5e30f8a13..a1f74b2b92 100644 --- a/wmake/scripts/sysFunctions +++ b/wmake/scripts/sysFunctions @@ -5,7 +5,7 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2018-2020 OpenCFD Ltd. +# Copyright (C) 2018-2022 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -212,7 +212,7 @@ then findLibrary() { local prefixDir localDir searchDir searchName - local file ext + local file found ext zshsplit searchDir=true @@ -264,6 +264,15 @@ then ## echo "search: $# $@" 1>&2 + # Split extLibraries on space: zsh needs shwordsplit for that + if [ -n "$ZSH_VERSION" ] + then + # $- contains 'y' if shwordsplit already active + zshsplit=1 + case "$-" in (*y*) unset zshsplit;; esac + setopt shwordsplit + fi + for searchDir in "$@" do [ -n "$searchDir" ] || continue @@ -272,8 +281,8 @@ then file="$prefixDir/$searchDir/$searchName$ext" if [ -f "$file" ] && [ -r "$file" ] then - echo "$file" # Found - return 0 + found="$file" # Found + break 2 fi done done @@ -281,6 +290,15 @@ then else # Directed search + # Split extLibraries on space: zsh needs shwordsplit for that + if [ -n "$ZSH_VERSION" ] + then + # $- contains 'y' if shwordsplit already active + zshsplit=1 + case "$-" in (*y*) unset zshsplit;; esac + setopt shwordsplit + fi + for file do [ -n "$file" ] || continue @@ -288,13 +306,25 @@ then do if [ -f "$file$ext" ] && [ -r "$file$ext" ] then - echo "$file$ext" # Found - return 0 + found="$file$ext" # Found + break 2 fi done done fi + # Restore old shwordsplit (zsh) + if [ -n "$zshsplit" ] + then + unsetopt shwordsplit + fi + + if [ -n "$found" ] + then + echo "$found" + return 0 + fi + return 2 }