Skip to content

Commit

Permalink
only grep if profile exists
Browse files Browse the repository at this point in the history
  • Loading branch information
hsoerensen committed Aug 6, 2024
1 parent 4f2fa6a commit 67e378d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,18 @@ get_telemetry_name() {
update_profile_setting() {
local setting_name="$1"
local new_value="$2"
local profile_file="${HOME}/voi/.profile"
local profile_file="${voi_home}/.profile"

if [[ -f "$profile_file" ]]; then
if grep -q "^export ${setting_name}=" "$profile_file"; then
escaped_value=$(printf '%s\n' "$new_value" | sed 's/[\/&]/\\&/g')
sed -i "s/^export ${setting_name}=.*/export ${setting_name}=${escaped_value}/" "$profile_file"
else
# Add the new setting if it doesn't exist
echo "export ${setting_name}=${new_value}" >> "$profile_file"
fi
else
echo "export ${setting_name}=${new_value}" >> "$profile_file"
fi
}

clone_environment_settings_to_profile() {
Expand Down

0 comments on commit 67e378d

Please sign in to comment.