#!/usr/bin/env bash

# put these on top of file

(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix

# absolute path working directory
basecwd=${PWD}
# base script directory
basedir=`dirname "$0"`
# absolute path script directory
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
# get script path
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

# Detect Cygwin or MinGW
case "$(uname)" in
  *CYGWIN*)
    basedir=$(cygpath -w "$basedir")
    # make cygwin bin as priority
    export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH"
    ;;
  *MINGW*)
    # make mingw bin as priority
    export PATH="/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH"
    ;;
esac

# parse and export .env file (dotenv)
if [ -f ".env" ]; then
  # Export the vars in .env into your shell:
  export $(egrep -v '^#' .env | xargs)
fi

## make non-binary file empty

truncate -s 0 "$1"