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; ...@@ -142,7 +142,7 @@ $| = 1;
# Module options # Module options
$Text::Wrap::columns = 76; $Text::Wrap::columns = 76;
&Getopt::Long::Configure("bundling"); # No option bundling
my $help = 0; my $help = 0;
my $version = 0; my $version = 0;
......
...@@ -590,7 +590,7 @@ $| = 1; ...@@ -590,7 +590,7 @@ $| = 1;
# Module options # Module options
$Text::Wrap::columns = 76; $Text::Wrap::columns = 76;
&Getopt::Long::Configure("bundling"); # No option bundling
my $help = 0; my $help = 0;
my $register; my $register;
......
...@@ -6,29 +6,50 @@ ...@@ -6,29 +6,50 @@
# installation to use. Not using "alternatives" because we want to be # installation to use. Not using "alternatives" because we want to be
# able to set per-user level defaults, not just system-wide defaults. # 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_dir="@OPENFOAM_SELECTOR_DATADIR@"
openfoam_selector_homefile="$HOME/@OPENFOAM_SELECTOR_HOME_FILE@" openfoam_selector_homefile="$HOME/@OPENFOAM_SELECTOR_HOME_FILE@"
openfoam_selector_sysfile="@OPENFOAM_SELECTOR_SYSCONFDIR@/@OPENFOAM_SELECTOR_SYSCONFIG_FILE@" openfoam_selector_sysfile="@OPENFOAM_SELECTOR_SYSCONFDIR@/@OPENFOAM_SELECTOR_SYSCONFIG_FILE@"
# The selection name # Get the selection name
unset openfoam_selection unset openfoam_selection
if test -f "$openfoam_selector_homefile"
then if [ -f "$openfoam_selector_homefile" ]
openfoam_selection=$(cat $openfoam_selector_homefile) then
elif test -f "$openfoam_selector_sysfile" # Home file
then openfoam_selection=$(cat "$openfoam_selector_homefile")
openfoam_selection=$(cat $openfoam_selector_sysfile) elif [ -f "$openfoam_selector_sysfile" ]
fi then
# System file
# 1st: get selection name -> directory name correspondence openfoam_selection=$(cat "$openfoam_selector_sysfile")
if test "$openfoam_selection" != "" -a -f "$openfoam_selector_dir/$openfoam_selection" fi
then
if [ -n "$openfoam_selection" ] && \
[ -f "$openfoam_selector_dir/$openfoam_selection" ]
then
# Resolve to OpenFOAM directory
openfoam_selection=$(cat "$openfoam_selector_dir/$openfoam_selection") openfoam_selection=$(cat "$openfoam_selector_dir/$openfoam_selection")
# 2nd: test for and source OpenFOAM etc/bashrc if [ -n "$openfoam_selection" ] && \
if test "$openfoam_selection" != "" -a -f "$openfoam_selection/etc/bashrc" [ -f "$openfoam_selection/etc/bashrc" ]
then then
. "$openfoam_selection/etc/bashrc" . "$openfoam_selection/etc/bashrc" ''
fi
fi 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