Skip to content

Commit

Permalink
Handle env files that don't end in newline
Browse files Browse the repository at this point in the history
  • Loading branch information
iainelder committed Jul 3, 2023
1 parent c77b175 commit 1218b37
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/profile/loadenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ function .env {
# 2. Add env name to shell prompt as Python's virtualenv does.
# 3. Move into the envdir so that commands like `pwd` work in the .envrc
# 4. Load direnv stdlib because env files may use it.
# 5. Load the .envrc without using direnv to use it in any directory.
# 6. Move back so that when Bash goes interactive I'm in the same place.
# 5. Load the file without using direnv to use it in any directory.
# 6. Ensure there is a newline after the file in case it didn't end with one.
# 7. Move back so that when Bash goes interactive I'm in the same place.
#
#
bash --init-file <(
Expand All @@ -35,6 +36,7 @@ function .env {
<(cat <<< "pushd '$envdir' > /dev/null") \
<(direnv stdlib) \
"$ENVDIR/$name" \
<(echo) \
<(cat <<< "popd > /dev/null") \
)
}
Expand Down

0 comments on commit 1218b37

Please sign in to comment.