Permalink
Browse files

Be sure to practice safe sed...

  • Loading branch information...
1 parent 869c7dc commit 9ba2ec0a2249ee59c59ce58ea8ebaaa7a05a3353 @wayneeseguin wayneeseguin committed Apr 8, 2010
Showing with 4 additions and 5 deletions.
  1. +2 −2 scripts/install
  2. +2 −3 scripts/manage
View
@@ -180,8 +180,8 @@ for ruby in $rvm_path/ruby-* $rvm_path/jruby-* $rvm_path/mput-* $rvm_path/rbx-*
for file in gem rake ; do
spinner
if [[ -s "$new_path/bin/$file" ]] ; then
- sed -i.orig -e '1,1s=.*=#!'"$new_path/bin/ruby=" "$new_path/bin/$file"
- rm -f "$new_path/bin/$file.orig"
+ sed -e '1,1s=.*=#!'"${new_path}/bin/ruby=" "${new_path}/bin/${file}" > "${new_path}/bin/${file}.new"
+ mv -f "$new_path/bin/$file.new" "$new_path/bin/$file"
chmod +x "$new_path/bin/$file"
fi
done
View
@@ -971,9 +971,8 @@ __rvm_inject_ruby_shebang() {
__rvm_actual_file $1
if [[ -f "$actual_file" ]] ; then
- #sed -i.orig -e '1,1s=.*=#!'"$rvm_ruby_home/bin/ruby=" $actual_file
- sed -e '1,1s=.*=#!'"/usr/bin/env ruby=" $actual_file > $actual+file.orig
- rm -f $actual_file.orig ; chmod +x "$actual_file"
+ sed -e '1,1s=.*=#!'"/usr/bin/env ruby=" ${actual_file} > "${actual_file}.new"
+ mv "${actual_file}.new" "${actual_file}" ; chmod +x "$actual_file"
fi ; unset actual_file
}

0 comments on commit 9ba2ec0

Please sign in to comment.