Permalink
Browse files

Slight cleanup on gemset_snapshot

  • Loading branch information...
1 parent 43d9edc commit bdc09deae76de087dfac3e98ef72eb7e11942b57 @wayneeseguin wayneeseguin committed Sep 9, 2010
Showing with 16 additions and 5 deletions.
  1. +16 −5 contrib/gemset_snapshot
@@ -1,14 +1,25 @@
#!/usr/bin/env bash
-echo "Snapshotting the current environment gem list into snapshot.gems"
+printf "\nBeginning snapshot of the current environment gem list into snapshot.gems\n"
+
file_name="snapshot.gems"
-echo '# system snapshot gemset file' > snapshot.gems
-for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | \tr ' ' ';') ; do
+
+gems=($(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | \tr ' ' ';'))
+
+for gem in "${gems[@]}" ; do
+
name="$(echo $gem | awk -F';' '{print $1}')"
- versions="$(echo $gem | awk -F';' '{print $2}' | sed 's#,# #g')"
- for version in $versions ; do
+
+ versions=($(echo $gem | awk -F';' '{print $2}' | sed 's#,# #g'))
+
+ for version in "${versions[@]}" ; do
+
echo "$name -v$version" >> "$file_name"
+
done ; unset version versions
+
done ; unset file_name
+printf "\nCompleted snapshot of the current environment gem list into snapshot.gems\n"
+
exit $?

0 comments on commit bdc09de

Please sign in to comment.