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