Skip to content

Commit

Permalink
chore: add comments for new script
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-pino committed Sep 23, 2024
1 parent 49fc926 commit 0b4eb09
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/set_native_env_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ add_or_update_var() {
local value="$3"

if grep -q '^\[env\]' "$file"; then
# If [env] table already exists
if ! grep -q "^\s*$key\s*=" "$file"; then
# If the key is not present
# Write the key just below the [env] line
awk -v key="$key" -v value="$value" '
/^\[env\]/ {
env_section = 1
Expand All @@ -19,6 +22,7 @@ add_or_update_var() {
' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
fi
else
# Otherwise, create the [env] table at the end and the new key
echo "[env]" >> "$file"
echo "$key = { value = \"$value\", relative = false }" >> "$file"
fi
Expand Down

0 comments on commit 0b4eb09

Please sign in to comment.