From c8d7a380b8789c08b10283aebcdf9f918905bc37 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 6 May 2019 15:48:18 +0200
Subject: [PATCH] Do not use function in define select mechanism (squashes
 aliases)

- bump VERSION
---
 openfoam-selector/VERSION                 |  2 +-
 openfoam-selector/openfoam-selector.sh.in | 65 +++++++++--------------
 2 files changed, 27 insertions(+), 40 deletions(-)

diff --git a/openfoam-selector/VERSION b/openfoam-selector/VERSION
index 21e8796..ee90284 100644
--- a/openfoam-selector/VERSION
+++ b/openfoam-selector/VERSION
@@ -1 +1 @@
-1.0.3
+1.0.4
diff --git a/openfoam-selector/openfoam-selector.sh.in b/openfoam-selector/openfoam-selector.sh.in
index 86ace04..f094f45 100644
--- a/openfoam-selector/openfoam-selector.sh.in
+++ b/openfoam-selector/openfoam-selector.sh.in
@@ -1,55 +1,42 @@
 # -*- sh -*-
 # Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
-# Copyright (C) 2018 OpenCFD Ltd.
+# Copyright (C) 2018-2019 OpenCFD Ltd.
 #
 # File installed for Bourne-shell startups to select which OPENFOAM
 # installation to use.  Not using "alternatives" because we want to be
 # able to set per-user level defaults, not just system-wide defaults.
-
-#
-# Define select mechanism as a function for later reuse
 #
-unset -f openfoam_select 2>/dev/null
-openfoam_select()
-{
+# Would be nice to define select mechanism as a function for later reuse
+# but that squashes aliases
+
 openfoam_selector_dir="@OPENFOAM_SELECTOR_DATADIR@"
 openfoam_selector_homefile="$HOME/@OPENFOAM_SELECTOR_HOME_FILE@"
 openfoam_selector_sysfile="@OPENFOAM_SELECTOR_SYSCONFDIR@/@OPENFOAM_SELECTOR_SYSCONFIG_FILE@"
 
-    # Get the selection name
-    unset openfoam_selection
-
-    if [ -f "$openfoam_selector_homefile" ]
-    then
-        # Home file
-        openfoam_selection=$(cat "$openfoam_selector_homefile")
-    elif [ -f "$openfoam_selector_sysfile" ]
-    then
-        # System file
-        openfoam_selection=$(cat "$openfoam_selector_sysfile")
-    fi
-
-
-    if [ -n "$openfoam_selection" ] && \
-       [ -f "$openfoam_selector_dir/$openfoam_selection" ]
+# The selection name
+unset openfoam_selection
+if [ -f "$openfoam_selector_homefile" ]
+then
+    openfoam_selection=$(cat "$openfoam_selector_homefile")
+elif [ -f "$openfoam_selector_sysfile" ]
+then
+    openfoam_selection=$(cat "$openfoam_selector_sysfile")
+fi
+
+if [ -n "$openfoam_selection" ] && \
+   [ -f "$openfoam_selector_dir/$openfoam_selection" ]
+then
+    # Resolve to OpenFOAM directory
+    openfoam_selection=$(cat "$openfoam_selector_dir/$openfoam_selection")
+
+    if [ -n "$openfoam_selection" ] && [ -f "$openfoam_selection/etc/bashrc" ]
     then
-        # Resolve to OpenFOAM directory
-
-        openfoam_selection=$(cat "$openfoam_selector_dir/$openfoam_selection")
-
-        if [ -n "$openfoam_selection" ] && \
-           [ -f "$openfoam_selection/etc/bashrc" ]
-        then
-            . "$openfoam_selection/etc/bashrc" ''
-        fi
+        . "$openfoam_selection/etc/bashrc" ''
     fi
+fi
 
-    # Cleanup
-    unset openfoam_selection openfoam_selector_dir
-    unset openfoam_selector_homefile openfoam_selector_sysfile
-}
-
-# Execute the above
-openfoam_select
+# Cleanup
+unset openfoam_selection openfoam_selector_dir
+unset openfoam_selector_homefile openfoam_selector_sysfile
 
 # -----------------------------------------------------------------------------
-- 
GitLab