From 9813af12ef2a8cad994936b402d150795c480ad2 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Mon, 26 Jul 2021 23:48:11 +0000
Subject: [PATCH] allow scripts to be passed to eic-shell

---
 install.sh | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/install.sh b/install.sh
index 587867dc8..6e31bca90 100755
--- a/install.sh
+++ b/install.sh
@@ -194,7 +194,7 @@ PREFIX=$PREFIX
 DISABLE_CVMFS_USAGE=${DISABLE_CVMFS_USAGE}
 
 function print_the_help {
-  echo "USAGE:  ./eic-shell [OPTIONS]"
+  echo "USAGE:  ./eic-shell [OPTIONS] [ -- COMMAND ]"
   echo "OPTIONAL ARGUMENTS:"
   echo "          -u,--upgrade    Upgrade the container to the latest version"
   echo "          -n,--no-cvmfs   Disable check for local CVMFS when updating. (D: enabled)"
@@ -202,7 +202,11 @@ function print_the_help {
   echo ""
   echo "  Start the eic-shell containerized software environment."
   echo ""
-  echo "EXAMPLE: ./eic-shell" 
+  echo "EXAMPLES: "
+  echo "  - Start an interactive shell: ./eic-shell" 
+  echo "  - Upgrade the container:      ./eic-shell --upgrade"
+  echo "  - Execute a single command:   ./eic-shell -- <COMMAND>"
+  echo ""
   exit
 }
 
@@ -223,6 +227,10 @@ while [ \$# -gt 0 ]; do
       print_the_help
       exit 0
       ;;
+    --)
+      shift
+      break
+      ;;
     *)
       echo "ERROR: unknown argument: \$key"
       echo "use --help for more info"
@@ -259,7 +267,7 @@ fi
 
 export ATHENA_PREFIX=$PREFIX/local
 export SINGULARITY_BINDPATH=$BINDPATH
-$SINGULARITY exec $SIF eic-shell
+$SINGULARITY exec $SIF eic-shell \$@
 EOF
 
 chmod +x eic-shell
-- 
GitLab