Lines 164-193
Link Here
|
164 |
|
164 |
|
165 |
|
165 |
|
166 |
do_update() { |
166 |
do_update() { |
167 |
if [[ ${#} -ne 1 ]]; then |
167 |
# Only set a symlink if there are any version of rails present |
168 |
die -q "Usage error: requires a slot to update" |
168 |
target=1 |
169 |
fi |
169 |
targets=( $(find_targets ) ) |
170 |
|
170 |
target=${targets[$(( ${target} - 1 ))]} |
171 |
local slot=${1} |
171 |
if [[ -f "${ROOT}/usr/bin/${target}" ]] ; then |
172 |
|
|
|
173 |
# symlink exists |
174 |
if [[ -L "${RAILS}" ]] ; then |
175 |
# update it if it's the same slot |
176 |
if [[ $(get_version) =~ ${slot} ]]; then |
177 |
set_symlink_by_slot ${slot} |
178 |
|
179 |
# set to highest if it's set to some slot that isn't around anymore |
180 |
elif [[ ! -f $(canonicalise ${RAILS}) ]]; then |
181 |
set_symlink_default |
182 |
# ignore |
183 |
else |
184 |
write_warning_msg "Current implementation, $(get_version), is not in slot ${slot}. Ignoring." |
185 |
fi |
186 |
# if it's a file, just warn about it being in the way |
187 |
elif [[ -e ${RAILS} ]]; then |
188 |
write_warning_msg "Can't set a new rails provider. There's a file in the way at ${RAILS}. You can try removing it manually, and then re-running this command." |
189 |
# nothing set, so set to 1st, which is highest available |
190 |
else |
191 |
set_symlink_default |
172 |
set_symlink_default |
192 |
fi |
173 |
fi |
193 |
} |
174 |
} |