This commit is contained in:
anki-code 2020-03-09 16:48:48 +03:00
parent 1e96605c50
commit feeb2c33cf

View File

@ -7,17 +7,40 @@
# Support three arguments (this recommend but not required): # Support three arguments (this recommend but not required):
# -f <file> Execute file on host, print the result and exit # -f <file> Execute file on host, print the result and exit
# -c <command> Execute command on host, print the result and exit # -c <command> Execute command on host, print the result and exit
# -v Verbose mode to debug # -v <level> 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 '<THIS> 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 # Move to current directory
@ -28,4 +51,7 @@ cd $CURRENT_DIR
# #
# Run the portable shell # Run the portable shell
# #
./your_portable_shell # $EXECUTE_FILE $EXECUTE_COMMAND $VERBOSE ./your_portable_shell
# Example:
# ./your_portable_shell $EXECUTE_FILE "${EXECUTE_COMMAND[@]}"