Skip to content

Commit

Permalink
fix loading .env
Browse files Browse the repository at this point in the history
The current method can cause issues if there are comments or empty lines in the .env file.
  • Loading branch information
bap2pecs committed Oct 19, 2024
1 parent 4c28ce5 commit 3f7397b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash
set -euo pipefail

# Load environment variables from .env file
echo "Load environment variables from .env file..."
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
# Load environment variables from the .env file
set -a
source $(pwd)/.env
set +a

if [ -z "$(echo ${WALLET_PASS})" ] || [ -z "$(echo ${BTCSTAKER_PRIVKEY})" ]; then
echo "Error: WALLET_PASS or BTCSTAKER_PRIVKEY environment variable is not set"
Expand Down

0 comments on commit 3f7397b

Please sign in to comment.