Now etc/tcshrc also works if sourced from .tcshrc. But an environment variable has to be set to make it work correctly as in this case diff does not work correctly

This commit is contained in:
Bernhard F.W. Gschaider 2014-08-03 20:31:58 +02:00 committed by Dominik Christ
parent edc6952f57
commit 48eabff312

View file

@ -1,5 +1,5 @@
#! /usr/bin/env zsh #! /usr/bin/env tcsh
#----------------------------------*-sh-*-------------------------------------- #---------------------------------*-tcsh-*-------------------------------------
# ========= | # ========= |
# \\ / F ield | foam-extend: Open Source CFD # \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | # \\ / O peration |
@ -32,17 +32,28 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if ( $?FOAM_SOURCED_FROM_ALIAS ) then if ( $?FOAM_SOURCED_FROM_ALIAS ) then
# Sourced from an alias # Sourced from an alias or .tcshrc
set sourced=($_) set sourced=($_)
shift sourced
set thisScript=$FOAM_SOURCED_FROM_ALIAS set thisScript=$FOAM_SOURCED_FROM_ALIAS
if ( $?sourced ) then
# sourced from .tcshrc
set sourced=($FOAM_SOURCED_FROM_ALIAS)
endif
shift sourced
# Clear the variable to make sure regular sourcing still works # Clear the variable to make sure regular sourcing still works
unsetenv FOAM_SOURCED_FROM_ALIAS unsetenv FOAM_SOURCED_FROM_ALIAS
else else
# regular sourcing # regular sourcing
set sourced=($_) set sourced=($_)
if ( $#sourced == 0 ) then
echo "Seems you sourced this script (etc/tcshrc from your foam-extend-installation) from .tcshrc."
echo "In that case tcsh has no way of telling where this script is located and is not able to set up the environment correctly"
echo "So before sourcing it set the location with 'setenv FOAM_SOURCED_FROM_ALIAS <path to the script>'"
echo "Or consider using a different shell"
endif
set thisScript=($sourced[2]) set thisScript=($sourced[2])
shift sourced shift sourced