Skip to content

Commit

Permalink
Fixed dollar char issue on bash
Browse files Browse the repository at this point in the history
  • Loading branch information
bayrakmustafa committed Apr 4, 2024
1 parent f445d5a commit e4d4887
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ COMMAND="$COMMAND ${CMD[@]}"

# Authentication Info
if [[ ! "${CMD[@]}" =~ .*"--help".* ]]; then
[ ! -z $USERNAME ] && COMMAND="$COMMAND -username=\"$USERNAME\""
[ ! -z $PASSWORD ] && COMMAND="$COMMAND -password=\"$PASSWORD\""
[ ! -z $USERNAME ] && COMMAND="$COMMAND -username=$(echo $USERNAME | awk '{gsub( /[(`$)]/, "\\\\&"); print $0}')"
[ ! -z $PASSWORD ] && COMMAND="$COMMAND -password=$(echo $PASSWORD | awk '{gsub( /[(`$)]/, "\\\\&"); print $0}')"

if [[ ! "${CMD[@]}" =~ .*"get_credential_ids".* ]]; then
[ ! -z $CREDENTIAL_ID ] && COMMAND="${COMMAND} -credential_id=\"${CREDENTIAL_ID}\""
[ ! -z $CREDENTIAL_ID ] && COMMAND="${COMMAND} -credential_id=${CREDENTIAL_ID}"
if [[ ! "${CMD[@]}" =~ .*"credential_info".* ]]; then
[ ! -z $TOTP_SECRET ] && COMMAND="${COMMAND} -totp_secret=\"${TOTP_SECRET}\""
[ ! -z $PROGRAM_NAME ] && COMMAND="${COMMAND} -program_name=\"${PROGRAM_NAME}\""
[ ! -z $FILE_PATH ] && COMMAND="${COMMAND} -input_file_path=\"${FILE_PATH}\""
[ ! -z $OUTPUT_PATH ] && COMMAND="${COMMAND} -output_dir_path=\"${OUTPUT_PATH}\""
[ ! -z $TOTP_SECRET ] && COMMAND="${COMMAND} -totp_secret=${TOTP_SECRET}"
[ ! -z $PROGRAM_NAME ] && COMMAND="${COMMAND} -program_name=${PROGRAM_NAME}"
[ ! -z $FILE_PATH ] && COMMAND="${COMMAND} -input_file_path=${FILE_PATH}"
[ ! -z $OUTPUT_PATH ] && COMMAND="${COMMAND} -output_dir_path=${OUTPUT_PATH}"
fi
fi
fi

RESULT=$(bash -c "set -e; $COMMAND")
RESULT=$(bash -c "set -e; $COMMAND 2>&1")
if [[ "$RESULT" =~ .*"Error".* || "$RESULT" =~ .*"Exception".* || "$RESULT" =~ .*"Missing required option".* || $RESULT =~ .*"Unmatched arguments from".* || $RESULT =~ .*"Unmatched argument".* || $RESULT =~ .*"Not a valid output directory".* ]]; then
echo "Something Went Wrong. Please try again."
echo "$RESULT"
Expand Down

0 comments on commit e4d4887

Please sign in to comment.