From feeb2c33cfdc2f403c8844dd7d521ed05e8a3473 Mon Sep 17 00:00:00 2001 From: anki-code Date: Mon, 9 Mar 2020 16:48:48 +0300 Subject: [PATCH] 0.4.4 --- entrypoint.sh | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f49327b..67d3893 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,17 +7,40 @@ # Support three arguments (this recommend but not required): # -f Execute file on host, print the result and exit # -c Execute command on host, print the result and exit -# -v Verbose mode to debug +# -v Verbose mode: 1 - verbose, 2 - super verbose +# +while getopts f:c:v: option +do +case "${option}" +in +f) EXECUTE_FILE=${OPTARG};; +c) EXECUTE_COMMAND=${OPTARG};; +v) VERBOSE=${OPTARG};; +esac +done + +## Example disabling option: +#if [[ $EXECUTE_COMMAND ]]; then +# echo ' entrypoint is not support command execution.' +# exit 1 +#fi + +## Example command argument: +#if [[ $EXECUTE_COMMAND ]]; then +# EXECUTE_COMMAND=(-c "${EXECUTE_COMMAND}") +#fi +# +#if [[ $EXECUTE_FILE ]]; then +# EXECUTE_COMMAND="" +#fi + +if [[ $VERBOSE != '' ]]; then + export XXH_VERBOSE=$VERBOSE +fi + +## Example of adding argument `-f` before +#EXECUTE_FILE=`[ $EXECUTE_FILE ] && echo -n "-f $EXECUTE_FILE" || echo -n ""` # -#while getopts f:c:v: option -#do -#case "${option}" -#in -#f) EXECUTE_FILE=${OPTARG};; -#c) EXECUTE_COMMAND=${OPTARG};; -#v) VERBOSE=${OPTARG};; -#esac -#done # # Move to current directory @@ -28,4 +51,7 @@ cd $CURRENT_DIR # # Run the portable shell # -./your_portable_shell # $EXECUTE_FILE $EXECUTE_COMMAND $VERBOSE +./your_portable_shell + +# Example: +# ./your_portable_shell $EXECUTE_FILE "${EXECUTE_COMMAND[@]}" \ No newline at end of file