Commit 28217694 authored by Mark Olesen's avatar Mark Olesen

ENH: reimplement startup scripts with functions

- this enables later direct command-line usage

- disable option bundling for selector and selector-menu so that the
  long options work with a single dash.
parent 93e72c71
......@@ -142,7 +142,7 @@ $| = 1;
# Module options
$Text::Wrap::columns = 76;
&Getopt::Long::Configure("bundling");
# No option bundling
my $help = 0;
my $version = 0;
......
......@@ -590,7 +590,7 @@ $| = 1;
# Module options
$Text::Wrap::columns = 76;
&Getopt::Long::Configure("bundling");
# No option bundling
my $help = 0;
my $register;
......
......@@ -6,29 +6,50 @@
# 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()
{
openfoam_selector_dir="@OPENFOAM_SELECTOR_DATADIR@"
openfoam_selector_homefile="$HOME/@OPENFOAM_SELECTOR_HOME_FILE@"
openfoam_selector_sysfile="@OPENFOAM_SELECTOR_SYSCONFDIR@/@OPENFOAM_SELECTOR_SYSCONFIG_FILE@"
# The selection name
unset openfoam_selection
if test -f "$openfoam_selector_homefile"
then
openfoam_selection=$(cat $openfoam_selector_homefile)
elif test -f "$openfoam_selector_sysfile"
then
openfoam_selection=$(cat $openfoam_selector_sysfile)
fi
# 1st: get selection name -> directory name correspondence
if test "$openfoam_selection" != "" -a -f "$openfoam_selector_dir/$openfoam_selection"
then
openfoam_selection=$(cat "$openfoam_selector_dir/$openfoam_selection")
# 2nd: test for and source OpenFOAM etc/bashrc
if test "$openfoam_selection" != "" -a -f "$openfoam_selection/etc/bashrc"
# 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
. "$openfoam_selection/etc/bashrc"
# System file
openfoam_selection=$(cat "$openfoam_selector_sysfile")
fi
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
. "$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
# -----------------------------------------------------------------------------
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment