Skip to content

Commit

Permalink
Clean up PATH after changing it (#56)
Browse files Browse the repository at this point in the history
Adding to the path without warning the user seems a little invasive.  
Save the original value and change it back after.
  • Loading branch information
joshschmitter committed Sep 23, 2021
1 parent c9d4458 commit ebe15a2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hooks/terraform-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
# OSX GUI apps do not pick up environment variables the same way as Terminal apps and there are no easy solutions,
# especially as Apple changes the GUI app behavior every release (see https://stackoverflow.com/q/135688/483528). As a
# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here.
original_path=$PATH
export PATH=$PATH:/usr/local/bin

# Store and return last failure from fmt so this can validate every directory passed before exiting
Expand All @@ -14,4 +15,7 @@ for file in "$@"; do
terraform fmt -diff -check "$file" || FMT_ERROR=$?
done

# reset path to the original value
export PATH=$original_path

exit ${FMT_ERROR}

0 comments on commit ebe15a2

Please sign in to comment.