scripts/gemsets in rvm-0.1.43 vs scripts/gemsets in rvm-0.1.44
- old
+ new
@@ -14,11 +14,11 @@
}
gemset_update() {
if [[ -z "$rvm_ruby_strings" ]]; then
$rvm_scripts_path/log "info" "Running gem update for all rubies and gemsets."
- rvm_ruby_strings="$(\ls "$rvm_gems_path" | grep -v '^\(doc\|cache\|@\|system\)' | tr '\n' ',')"
+ rvm_ruby_strings="$(\ls "$rvm_gems_path" | grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')"
else
$rvm_scripts_path/log "info" "Running gem update for the specified rubies."
fi
export rvm_ruby_strings
$rvm_scripts_path/set "gem" "update"
@@ -152,20 +152,31 @@
fi ; unset gemdir
}
# Migrate gemsets from ruby X to ruby Y
gemset_copy() {
- source_ruby="$(echo $gems_args | awk '{print $1}')"
- destination_ruby="$(echo $gems_args | awk '{print $2}')"
- if [[ -z "$source_ruby" ]] ; then
+ local source_ruby="$(echo "$gems_args" | awk '{print $1}')"
+ local destination_ruby="$(echo "$gems_args" | awk '{print $2}')"
+
+ if [[ -z "$destination_ruby" || -z "$source_ruby" ]] ; then
$rvm_scripts_path/log "error" "Source and destination must be specified: 'rvm gemset copy X Y'"
+ return 1
fi
- if [[ -z "$destination_ruby" ]] ; then
- $rvm_scripts_path/log "error" "Source and destination must be specified: 'rvm gemset copy X Y'"
+
+ local source_path="$(rvm_silence_logging=1 rvm "$source_ruby" gem env gemdir)"
+ local destination_path="$(rvm_silence_logging=1 rvm "$destination_ruby" gem env gemdir)"
+
+ if [[ -z "$source_path" ]]; then
+ $rvm_scripts_path/log "error" "Unable to expand ruby '$source_ruby'"
+ return 1
fi
- source_path="$(rvm $source_ruby gem env gemdir | tail -n 1)"
- destination_path="$(rvm $destination_ruby gem env gemdir | tail -n 1)"
+
+ if [[ -z "$destination_path" ]]; then
+ $rvm_scripts_path/log "error" "Unable to expand ruby '$destination_ruby'"
+ return 1
+ fi
+
if [[ -d "$source_path" ]] ; then
if [[ ! -d "$destination_path" ]] ; then mkdir -p $destination_path ; fi
$rvm_scripts_path/log "info" "Copying gemset from $source_ruby to $destination_ruby"
for dir in bin doc gems specifications ; do
mkdir -p "$destination_path/$dir"
@@ -175,12 +186,10 @@
(rvm "$destination_ruby" ; gemset_pristine)
else
$rvm_scripts_path/log "error" "Gems directory does not exist for $source_path ($source_path)"
return 1
fi
-
- unset source_ruby destination_ruby source_path destination_path
}
gemset_export() {
rvm_file_name="${rvm_file_name:-$gems_args}"
@@ -200,11 +209,11 @@
$rvm_scripts_path/log "info" "Exporting current environments gemset to $rvm_file_name"
touch $rvm_file_name
echo "# $rvm_file_name generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator" > $rvm_file_name
- for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | tr ' ' ';') ; do
+ for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | \tr ' ' ';') ; do
name="$(echo $gem | awk -F';' '{print $1}')"
if [[ -z "$rvm_latest_flag" ]] ; then
versions="$(echo $gem | awk -F';' '{print $2}' | sed 's#,# #g')"
for version in $versions ; do
echo "$name -v$version" >> $rvm_file_name
@@ -379,11 +388,11 @@
live_cache_path="$GEM_HOME/cache"
mkdir -p "$temporary_cache_path"
$rvm_scripts_path/log "info" "Moving active gems into temporary cache..."
while read -r used_gem; do
gem_name="$(echo "$used_gem" | sed -e 's/ .*//')"
- versions="$(echo "$used_gem" | sed -e 's/.* (//' -e 's/)//' | tr ', ' ' ')"
+ versions="$(echo "$used_gem" | sed -e 's/.* (//' -e 's/)//' | \tr ', ' ' ')"
for version in $versions; do
cached_gem_name="${gem_name}-${version}.gem"
cached_file_path="${live_cache_path}/${cached_gem_name}"
if [[ -f "$cached_file_path" ]]; then
mv "$cached_file_path" "${temporary_cache_path}/${cached_gem_name}"
@@ -401,11 +410,11 @@
}
# Loads the default gemsets for the current interpreter and gemset.
gemset_initial() {
$rvm_scripts_path/log "info" "Importing initial gemsets for $(__rvm_environment_identifier)."
- mkdir -p "$rvm_gemsets_path/$(echo "$rvm_ruby_string" | tr '-' '/')" 2>/dev/null
+ mkdir -p "$rvm_gemsets_path/$(echo "$rvm_ruby_string" | \tr '-' '/')" 2>/dev/null
for gemsets_path in $(__rvm_ruby_string_paths_under "$rvm_gemsets_path") ; do
if [[ -n "$rvm_gemset_name" ]] ; then
if [[ -s "${gemsets_path}/${rvm_gemset_name}.gems" ]] ; then
(source "$rvm_scripts_path/rvm"; rvm gemset import "${gemsets_path}/${rvm_gemset_name}.gems") > /dev/null
fi
@@ -435,10 +444,10 @@
if [[ "import" = "$action" ]] || [[ "load" = "$action" ]] ; then
if [[ -z "$rvm_ruby_strings" ]]; then
gemset_import
else
original_env="$(__rvm_environment_identifier)"
- for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr "," " "); do
+ for rvm_ruby_string in $(echo "$rvm_ruby_strings" | \tr "," " "); do
__rvm_become
gemset_import
done
__rvm_become "$original_env"
unset original_env