scripts/environment-convertor in rvm-1.0.11 vs scripts/environment-convertor in rvm-1.0.13

- old
+ new

@@ -5,11 +5,12 @@ unset GREP_COLOR unset GREP_OPTIONS source "$rvm_path/scripts/base" -convert_path_to_fish() { +convert_path_to_fish() +{ local parts path_parts path_part="$1" parts="$(echo "$path_part" | sed -e 's#:\$PATH##' -e "s#:#\" \"#g" -e "s#^export \\([^[:space:]]*\\)=##")" @@ -21,23 +22,27 @@ end " return 0 } -convert_unset_to_fish() { +convert_unset_to_fish() +{ sed 's#^unset #set -e #' } -convert_exports_to_fish() { +convert_exports_to_fish() +{ sed -e "s#:#' '#g" -e "s#^\\(export \\)\\{0,1\\}\\([^[:space:]]*\\)=#set -x \\2 #" } -contents_of_environment_file() { +contents_of_environment_file() +{ cat "$rvm_path/environments/$(__rvm_environment_identifier)" } -convert_to_shell() { +convert_to_shell() +{ convert_path_to_fish "$(contents_of_environment_file | \grep '^export PATH=')" while read -r shell_line; do if echo "$shell_line" | \grep -q '^unset '; then echo "$shell_line" | convert_unset_to_fish else @@ -45,10 +50,11 @@ fi done < <(contents_of_environment_file | \grep -v '^export [^=]*$' | \grep -v '^export PATH=') unset shell_line } -ensure_has_shell() { +ensure_has_shell() +{ for item in "path" "unset" "exports"; do command -v "convert_${item}_to_${1}" >/dev/null || return 1 done; unset item }