Commit 9de1e703 authored by Roque's avatar Roque

bug fixing: check invalid dataset name before store it in local config file

- fix indentation
parent 5775db93
...@@ -62,6 +62,7 @@ function helpReadme { ...@@ -62,6 +62,7 @@ function helpReadme {
} }
function checkParameters { function checkParameters {
re='^[_A-Za-z.0-9-]*$'
if [ ! -f $TEMPLATE_FILE ]; then if [ ! -f $TEMPLATE_FILE ]; then
echo echo
echo -e "${ORANGE}[ERROR] File '$TEMPLATE_FILE' not found!${NC}" >&2; return 1 echo -e "${ORANGE}[ERROR] File '$TEMPLATE_FILE' not found!${NC}" >&2; return 1
...@@ -91,6 +92,19 @@ function checkParameters { ...@@ -91,6 +92,19 @@ function checkParameters {
fi fi
fi fi
EBULK_DATASET_FILE="$DATASET_DIR$EBULK_DATASET_FILE_NAME" EBULK_DATASET_FILE="$DATASET_DIR$EBULK_DATASET_FILE_NAME"
if ! [[ $REFERENCE =~ $re ]] ; then
if [ "$REFERENCE" = "." ] && [[ -z "$STORAGE" ]] ; then
echo
echo -e "${ORANGE}[ERROR] You are not in a dataset directory ${GREEN}'$REFERENCE'${ORANGE}.${NC}"
echo
else
echo
echo -e "${ORANGE}[ERROR] Error in argument: invalid dataset name ${GREEN}'$REFERENCE'${ORANGE}.${NC}"
echo -e "${ORANGE}[ERROR] Only alphanumerics, dots ( . ), underscores ( _ ) and hyphens ( - ) are allowed.${NC}"
echo
fi
helpReadme >&2; return 1
fi
if [[ $DATASET_DIR != $REFERENCE ]]; then if [[ $DATASET_DIR != $REFERENCE ]]; then
if [ "$REFERENCE" = "." ] ; then if [ "$REFERENCE" = "." ] ; then
REFERENCE=$(basename "$DATASET_DIR") REFERENCE=$(basename "$DATASET_DIR")
...@@ -124,7 +138,6 @@ function checkParameters { ...@@ -124,7 +138,6 @@ function checkParameters {
if [ "$DATA_SET" == "." ] ; then if [ "$DATA_SET" == "." ] ; then
DATA_SET=$(basename $(pwd)) DATA_SET=$(basename $(pwd))
fi fi
re='^[_A-Za-z.0-9-]*$'
if ! [[ $DATA_SET =~ $re ]] ; then if ! [[ $DATA_SET =~ $re ]] ; then
if [ "$DATA_SET" = "." ] && [[ -z "$STORAGE" ]] ; then if [ "$DATA_SET" = "." ] && [[ -z "$STORAGE" ]] ; then
echo echo
...@@ -750,6 +763,9 @@ case $OPERATION in ...@@ -750,6 +763,9 @@ case $OPERATION in
echo echo
fi fi
echo "### DATASET DOWNLOAD ###" echo "### DATASET DOWNLOAD ###"
if [ "$ALWAYS_YES" = "true" ] ; then
echo "[always yes mode]"
fi
echo echo
if [ "$DISCARD_CHANGES" != "" ] ; then if [ "$DISCARD_CHANGES" != "" ] ; then
DISCARD_CHANGES_FILE="$DATASET_DIR$DISCARD_CHANGES_FILE_NAME" DISCARD_CHANGES_FILE="$DATASET_DIR$DISCARD_CHANGES_FILE_NAME"
...@@ -759,8 +775,10 @@ case $OPERATION in ...@@ -759,8 +775,10 @@ case $OPERATION in
echo -e "** The dataset will be downloaded in the specified directory: $DATASET_DIR" echo -e "** The dataset will be downloaded in the specified directory: $DATASET_DIR"
fi fi
echo echo
if [ "$ALWAYS_YES" = "false" ] ; then
read -n 1 -s -r -p "Press any key to continue" read -n 1 -s -r -p "Press any key to continue"
echo echo
fi
runProcess runProcess
;; ;;
push) push)
...@@ -799,11 +817,16 @@ case $OPERATION in ...@@ -799,11 +817,16 @@ case $OPERATION in
esac esac
fi fi
echo "### DATASET INGESTION ###" echo "### DATASET INGESTION ###"
if [ "$ALWAYS_YES" = "true" ] ; then
echo "[always yes mode]"
else
echo echo
echo -e "** The tool will look for dataset files in the specified $MESSAGE" echo -e "** The tool will look for dataset files in the specified $MESSAGE"
echo -e "** Please make sure to put your dataset files there for ingestion." echo -e "** Please make sure to put your dataset files there for ingestion."
echo echo
read -n 1 -s -r -p "Press any key to continue" read -n 1 -s -r -p "Press any key to continue"
fi
echo echo
runProcess runProcess
;; ;;
......
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