#!/usr/bin/env bash

echoerr() { printf "%s\n" "$*" >&2; }

echo Commandline:
echo
echo "$0" "$@"
echo
echo ---------------------------------------------------------------------------
echo Attachment:
if [ -f "$1" ]; then
    echo "File $1 exists."
    ls -la "$1"
else
    echo "File $1 does not exist."
fi
echo

envirnonment_variables=$(env | jq -R 'split("=") | {(.[0]): .[1]}' | jq -s add)

if [ -n "$RESULT_FILE" ]; then
    echo "$envirnonment_variables"     > "$RESULT_FILE"
fi

echo "$envirnonment_variables"

echoerr "StdErr Output example"

echo "Mount Info"
cat /proc/self/mountinfo 

if [[ -n "$FORCE_EXITCODE" && "$FORCE_EXITCODE" =~ ^[0-9]+$ ]]; then
    exit "$FORCE_EXITCODE"
fi
