Skip to content

Commit

Permalink
fix: no sudo if FVM_SYMLINK_TARGET is set
Browse files Browse the repository at this point in the history
  • Loading branch information
busla committed Nov 26, 2024
1 parent 3ef5b96 commit edbc24a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,22 @@ if ! mv "$FVM_DIR/fvm" "$FVM_DIR_BIN"; then
fi

# Create a symlink
if ! sudo ln -sf "$FVM_DIR_BIN/fvm" "$SYMLINK_TARGET"; then
error "Failed to create symlink."
if [ -n "${FVM_SYMLINK_TARGET}" ]; then
# Skip sudo if FVM_SYMLINK_TARGET is explicitly set
if ! ln -sf "$FVM_DIR_BIN/fvm" "$SYMLINK_TARGET"; then
echo "Failed to create symlink at $SYMLINK_TARGET."
exit 1
fi
else
# Use sudo for default SYMLINK_TARGET
if ! sudo ln -sf "$FVM_DIR_BIN/fvm" "$SYMLINK_TARGET"; then
echo "Failed to create symlink at $SYMLINK_TARGET with sudo."
exit 1
fi
fi

echo "Symlink created at $SYMLINK_TARGET pointing to $FVM_DIR_BIN/fvm"

tildify() {
if [[ $1 = $HOME/* ]]; then
local replacement=\~/
Expand Down

0 comments on commit edbc24a

Please sign in to comment.