Skip to content

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaiyarasiganeshalingam committed Nov 24, 2024
1 parent b009d87 commit 40e74b5
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,20 @@ export_env_file() {

# Read the .env file and export each variable to the environment
while IFS='=' read -r key value; do
# Ignore lines starting with '#' (comments) or empty lines
if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then
# Trim surrounding whitespace from key and value
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs)
# Export the key-value pair to the environment
export "$key=$value"
fi
# Ignore lines starting with '#' (comments) or empty lines
case "$key" in
\#*|"")
# Skip comments or empty lines
continue
;;
*)
# Trim surrounding whitespace from key and value
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs)
# Export the key-value pair to the environment
export "$key=$value"
;;
esac
done < "$file_path"

echo "Environment variables loaded from $file_path."
Expand Down

0 comments on commit 40e74b5

Please sign in to comment.