scripts/repair in rvm-1.0.10 vs scripts/repair in rvm-1.0.11
- old
+ new
@@ -1,44 +1,78 @@
#!/usr/bin/env bash
source "$rvm_path/scripts/base"
usage() {
- echo "Usage: rvm repair {wrappers,symlinks,environments,archives,all}" >&2
- return 1
+ printf "
+ Usage:
+
+ rvm repair [option]
+
+ Options:
+ wrappers - Repair wrappers
+ symlinks - Repair symlinks
+ environments - Repair environments
+ archives - Repair archives
+ all - Repair all of the above
+
+"
}
repair_wrappers() {
- __rvm_regenerate_wrappers
+
+ local wrapper_ruby_name
+
+ "$rvm_path/scripts/log" "info" "Regenerating all wrappers..."
+
+ while read -r wrapper_ruby_name ; do
+
+ "$rvm_path/scripts/log" "info" \
+ "Regenerating wrappers for $wrapper_ruby_name"
+
+ __rvm_run "wrappers.regenerate" \
+ "\"$rvm_path/scripts/wrapper\" '$wrapper_ruby_name'"
+
+ done < <("$rvm_path/scripts/list" gemsets strings)
+
+ "$rvm_path/scripts/log" "info" "Wrappers regenerated"
+
}
# Removes stale symlinks in $rvm_bin_path, likely
# related to wrappers.
repair_symlinks() {
+
+ "$rvm_path/scripts/log" "info" "Repairing symlinks..."
+
(
builtin cd "${rvm_bin_path:-"$rvm_path/bin"}"
for executable_name in $(\find \. -type l); do
[[ -e "$executable_name" || "$(readlink "$executable_name")" != "$rvm_path/wrappers/"* ]] && continue
if [[ -f "$executable_name" ]] ; then
"$rvm_path/scripts/log" "info" \
- "Removing stale symlink from $(basename "$executable_name")"
+ "removing stale symlink from $(basename "$executable_name")"
\rm -f "$executable_name"
fi
done
)
+
+ "$rvm_path/scripts/log" "info" "Symlinks repaired"
}
# Regenerates each symlink file.
repair_environments() {
local environment_name environments
+ "$rvm_path/scripts/log" "info" "Regenerating environments..."
+
environments=($(cd "$rvm_path/environments" ; find . -maxdepth 1 -mindepth 1 -type f))
for environment_name in "${environments[@]//.\/}" ; do
[[ -L "$rvm_path/environments/$environment_name" ]] && continue
@@ -55,16 +89,21 @@
__rvm_ensure_has_environment_files
)
done
+
+ "$rvm_path/scripts/log" "info" "Environments regenerated"
+
+ return 0
}
# Removes archives that have incorrect md5 sums.
repair_archives() {
local archive_file archives stored_md5sum
+ "$rvm_path/scripts/log" "info" "Repairing archives..."
archives=($(cd "${rvm_archives_path:-"$rvm_path/archives"}" ; find . -maxdepth 1 -mindepth 1 -type f))
for archive_file in "${archives[@]//.\/}" ; do
@@ -81,10 +120,12 @@
rm -rf "${rvm_archives_path:-"$rvm_path/archives"}/$archive_file"
fi
fi
done
+ "$rvm_path/scripts/log" "info" "Archives repaired"
+
return 0
}
repair_all() {
@@ -94,19 +135,17 @@
repair_environments
repair_wrappers
- "$rvm_path/scripts/log" "info" \
- "symlinks, archives and environments have been repaired."
-
return 0
}
args=($*)
-action="${args[0]}"
-args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
+action="${args[$__array_start]}"
+args[$__array_start]=""
+args=(${args[@]})
if [[ -z "$action" ]]; then
usage
exit $?
fi
@@ -115,9 +154,10 @@
all) repair_all ;;
symlinks) repair_symlinks ;;
environments) repair_environments ;;
archives) repair_archives ;;
wrappers) repair_wrappers ;;
- *) usage ;;
+ help) usage ;;
+ *) usage >&2 ; exit 1 ;;
esac
exit $?