Check shell profile is writeable before modifying

The `set -e` at the top of the script causes the installation to fail to
complete if the shell profile is not writeable. Checking file existence
only is not enough.
This commit is contained in:
Alex Cruice 2015-05-25 14:49:44 +10:00 committed by Eelco Dolstra
parent c780c1124e
commit ad0dc41899

View file

@ -92,7 +92,7 @@ p=$NIX_LINK/etc/profile.d/nix.sh
added=
for i in .bash_profile .bash_login .profile; do
fn="$HOME/$i"
if [ -e "$fn" ]; then
if [ -w "$fn" ]; then
if ! grep -q "$p" "$fn"; then
echo "modifying $fn..." >&2
echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn