From 947b42690d8c8fedfaeae8b20d42bef33ed28832 Mon Sep 17 00:00:00 2001
From: Marcel Loose <loose@astron.nl>
Date: Wed, 28 Nov 2007 12:43:13 +0000
Subject: [PATCH] Bug 1127: * Python prior to verison 2.5 does not support the
 '--version' option.   Use '-V' instead. * Output of 'python -V' is sent to
 stderr, which is not caught when binding   file descriptors 1 and 2. Use '|&
 cat --' instead. * Fixed a number of csh syntax errors.

---
 LCS/Tools/src/lofarinit.csh | 11 ++++++-----
 LCS/Tools/src/lofarinit.sh  |  3 ++-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/LCS/Tools/src/lofarinit.csh b/LCS/Tools/src/lofarinit.csh
index d311e40e81d..9428a62ee0a 100644
--- a/LCS/Tools/src/lofarinit.csh
+++ b/LCS/Tools/src/lofarinit.csh
@@ -29,10 +29,11 @@
 set a_root = . #filled in by install
 
 # Get python version.
-set a_pyv=`python --version 2>&1`
-set a_pyvv=`echo $a_pyv | sed -e "s/Python /([0.9]\.[0-9]\).*/\1/"`
-if test "$a_pyv" = "$a_pyvv" then
-  set a_pyvv=2.5
+set a_pyv=`python -V |& cat --`
+set a_pyvv=`echo $a_pyv | sed -e "s/Python \([0-9]\.[0-9]\).*/\1/"`
+# Fall-back: if python cannot be found assume Python 2.4
+if ("$a_pyv" == "$a_pyvv") then
+  set a_pyvv=2.4
 endif
 
 # Only modify path variables if $a_root is an existing directory.
@@ -79,7 +80,7 @@ else
     if (! $?PYTHONPATH) then
         setenv PYTHONPATH $a_pyt
     else
-        setenv PYTHONPATH $a_pyt:$PYTHONPATH
+        setenv PYTHONPATH ${a_pyt}:$PYTHONPATH
     endif
 
     # Create a .glishrc.post in the HOME directory to append
diff --git a/LCS/Tools/src/lofarinit.sh b/LCS/Tools/src/lofarinit.sh
index 100082e5cb7..b83fa30d29c 100644
--- a/LCS/Tools/src/lofarinit.sh
+++ b/LCS/Tools/src/lofarinit.sh
@@ -29,8 +29,9 @@
 lfr_root=. #filled in by install
 
 # Get python version.
-a_pyv=`python --version 2>&1`
+a_pyv=`python -V 2>&1`
 a_pyvv=`echo $a_pyv | sed -e "s/Python \([0-9]\.[0-9]\).*/\1/"`
+# Fall-back: if python cannot be found assume Python 2.4
 if test "$a_pyv" = "$a_pyvv"; then
   a_pyvv=2.4
 fi
-- 
GitLab