From edc6952f57fde09878e6573b85a2d834a72f777b Mon Sep 17 00:00:00 2001 From: "Bernhard F.W. Gschaider" Date: Fri, 1 Aug 2014 01:15:57 +0200 Subject: [PATCH] Make sure that the aliases that source the tcshrc still work --- etc/getVariables.py | 5 +++++ etc/tcshrc | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/etc/getVariables.py b/etc/getVariables.py index b8ad0b0d8..248f9862e 100755 --- a/etc/getVariables.py +++ b/etc/getVariables.py @@ -260,6 +260,11 @@ class CshConvert(ShellConvert): pos=val.find("export ") val=val.replace("export ","setenv ",1) val=val[:pos]+val[pos:].replace("="," ",1) + + # Prefix with a variable that tells the script that it is sourced from an alias + if val.find("source")>=0: + val=("setenv FOAM_SOURCED_FROM_ALIAS %s/tcshrc ; " % here)+val + return "alias %s '%s'" % (n,val) class TcshConvert(CshConvert): diff --git a/etc/tcshrc b/etc/tcshrc index 6a56783e8..460c290c2 100755 --- a/etc/tcshrc +++ b/etc/tcshrc @@ -31,11 +31,23 @@ # #------------------------------------------------------------------------------ -set sourced=($_) -set thisScript=($sourced[2]) +if ( $?FOAM_SOURCED_FROM_ALIAS ) then + # Sourced from an alias + set sourced=($_) + shift sourced -shift sourced -shift sourced + set thisScript=$FOAM_SOURCED_FROM_ALIAS + + # Clear the variable to make sure regular sourcing still works + unsetenv FOAM_SOURCED_FROM_ALIAS +else + # regular sourcing + set sourced=($_) + set thisScript=($sourced[2]) + + shift sourced + shift sourced +endif set thisDir=`python -c "from os.path import *;import sys;sys.stdout.write(dirname(abspath(join(curdir,'$thisScript'))))"`