cli 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. #!/usr/bin/env bash
  2. __rvm_parse_args_find_known_flags()
  3. {
  4. \typeset _args_array_name _temp_var
  5. \typeset -a _new_args
  6. _args_array_name="$1"
  7. (( $# == 0 )) || shift
  8. _new_args=()
  9. while
  10. (( $# ))
  11. do
  12. case "$1" in
  13. (--verify-downloads)
  14. export "rvm_verify_downloads_flag_cli"="${2:-}"
  15. shift
  16. ;;
  17. (--force|--verbose|--debug|--quiet|--silent|--create)
  18. export "rvm_${1#--}_flag=1"
  19. ;;
  20. (--only-path)
  21. _temp_var="${1#--}"
  22. export "rvm_${_temp_var//-/_}_flag=1"
  23. ;;
  24. (--32|--64)
  25. rvm_architectures+=( "${1#--}" )
  26. rvm_disable_binary_flag=1
  27. ;;
  28. (--universal)
  29. rvm_architectures+=( "32" "64" )
  30. rvm_disable_binary_flag=1
  31. ;;
  32. (--patches|--patch)
  33. __rvm_custom_separated_array rvm_patch_names , "${2:-}"
  34. rvm_patch_original_pwd="$PWD"
  35. rvm_disable_binary_flag=1
  36. shift
  37. ;;
  38. (--autolibs=*)
  39. export rvm_autolibs_flag="${1#*=}"
  40. ;;
  41. (--)
  42. shift
  43. _new_args+=( "$@" )
  44. shift $#
  45. ;;
  46. (*)
  47. _new_args+=( "$1" )
  48. ;;
  49. esac
  50. (( $# == 0 )) || shift # check in case shifted already
  51. done
  52. eval "${_args_array_name}+=( \"\${_new_args[@]}\" )"
  53. }
  54. __rvm_parse_args_error_finding_project_file()
  55. {
  56. unset RVM_PROJECT_PATH
  57. case $? in
  58. 101)
  59. true # should be printed already
  60. ;;
  61. *)
  62. rvm_error_message="Could not determine which Ruby to use; $rvm_token should contain .rvmrc or .versions.conf or .ruby-version or .rbfu-version or .rbenv-version, or an appropriate line in Gemfile."
  63. ;;
  64. esac
  65. rvm_action="error"
  66. }
  67. __rvm_parse_args()
  68. {
  69. \typeset _string
  70. export rvm_ruby_string
  71. rvm_action="${rvm_action:-""}"
  72. rvm_parse_break=0
  73. if
  74. [[ " $* " == *" --trace "* ]]
  75. then
  76. echo "$@"
  77. __rvm_print_headline
  78. fi
  79. while
  80. [[ -n "$next_token" ]]
  81. do
  82. rvm_token="$next_token"
  83. if
  84. (( $# > 0 ))
  85. then
  86. next_token="$1"
  87. shift
  88. else
  89. next_token=""
  90. fi
  91. case "$rvm_token" in
  92. [0-9a-zA-ZuU]*|@*) # Commands, Rubies and Gemsets
  93. case "$rvm_token" in
  94. use)
  95. rvm_action="$rvm_token"
  96. rvm_verbose_flag=1
  97. __rvm_file_env_check_unload
  98. if
  99. [[ -n "${next_token:-}" && ! -d "${next_token:-}" &&
  100. "${next_token:-}" != "-"* && "${next_token:-}" != "@"*
  101. ]]
  102. then
  103. rvm_ruby_interpreter="$next_token"
  104. rvm_ruby_string="$next_token"
  105. rvm_ruby_strings="$next_token"
  106. next_token="${1:-}"
  107. (( $# == 0 )) || shift
  108. elif
  109. [[ -z "${next_token:-}" ]] &&
  110. __rvm_project_dir_check .
  111. then
  112. __rvm_rvmrc_tools try_to_read_ruby . ||
  113. __rvm_parse_args_error_finding_project_file
  114. fi
  115. ;;
  116. install|uninstall|reinstall|try_install)
  117. export ${rvm_token}_flag=1
  118. rvm_action=$rvm_token
  119. ;;
  120. gemset)
  121. rvm_action=$rvm_token
  122. rvm_ruby_args=()
  123. __rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@"
  124. : rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:
  125. next_token="${rvm_ruby_args[__array_start]}"
  126. rvm_gemset_name="${rvm_ruby_args[__array_start+1]}"
  127. case "${next_token:-help}" in
  128. (help)
  129. true
  130. ;;
  131. (use|delete)
  132. [[ "delete" != "$next_token" ]] || rvm_delete_flag=1
  133. [[ "use" != "$next_token" ]] || rvm_action+="_$next_token"
  134. case "$rvm_gemset_name" in
  135. *${rvm_gemset_separator:-"@"}*)
  136. rvm_ruby_string="${rvm_gemset_name%%${rvm_gemset_separator:-"@"}*}"
  137. rvm_gemset_name="${rvm_gemset_name##*${rvm_gemset_separator:-"@"}}"
  138. if
  139. [[ "${rvm_ruby_string:-""}" != "${rvm_gemset_name:-""}" ]]
  140. then
  141. rvm_ruby_string="$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name"
  142. fi
  143. rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator:-"@"}$rvm_gemset_name"
  144. ;;
  145. ("")
  146. rvm_error "Gemset was not given.\n Usage:\n rvm gemset $rvm_gemset_name <gemsetname>\n"
  147. return 1
  148. ;;
  149. esac
  150. ;;
  151. esac
  152. rvm_parse_break=1
  153. ;;
  154. gemdir|gempath|gemhome)
  155. rvm_ruby_args=("$rvm_token")
  156. rvm_action="gemset"
  157. rvm_gemdir_flag=1
  158. if
  159. [[ "system" == "$next_token" ]]
  160. then
  161. rvm_system_flag=1
  162. next_token="${1:-}"
  163. (( $# == 0 )) || shift
  164. fi
  165. if
  166. [[ "user" == "$next_token" ]]
  167. then
  168. rvm_user_flag=1
  169. next_token="${1:-}"
  170. (( $# == 0 )) || shift
  171. fi
  172. ;;
  173. pkg)
  174. rvm_action="$rvm_token"
  175. __rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@"
  176. rvm_parse_break=1
  177. ;;
  178. do|exec)
  179. if
  180. [[ -z "$next_token" ]]
  181. then
  182. rvm_action="error"
  183. rvm_error_message="'rvm $rvm_token' must be followed by arguments."
  184. break
  185. fi
  186. rvm_action="do"
  187. rvm_ruby_args=("$next_token" "$@")
  188. rvm_parse_break=1
  189. ;;
  190. gem|rake|ruby)
  191. [[ "$rvm_token" == "ruby" ]] &&
  192. case $rvm_action in
  193. install|reinstall|use|remove)
  194. rvm_ruby_string=ruby
  195. rvm_ruby_strings=ruby
  196. continue
  197. ;;
  198. esac
  199. # deprecated 2011.10.11 for RVM 1.9.0, removed 2012.09.13 for RVM 1.16.0
  200. rvm_action=error
  201. rvm_error_message="Please note that \`rvm $rvm_token ...\` was removed, try \`$rvm_token $next_token $*\` or \`rvm all do $rvm_token $next_token $*\` instead."
  202. ;;
  203. fetch|version|remote_version|reset|debug|reload|update|monitor|notes|implode|seppuku|env|unexport|automount|prepare)
  204. rvm_action=$rvm_token
  205. ;;
  206. doctor)
  207. rvm_action=notes
  208. ;;
  209. mount)
  210. rvm_action=$rvm_token
  211. while
  212. [[ -n "${next_token:-}" ]] &&
  213. [[ -x "${next_token:-}" ||
  214. -d "${next_token:-}" ||
  215. "${next_token:-}" == http* ||
  216. "${next_token:-}" == *tar.bz2 ||
  217. "${next_token:-}" == *tar.gz
  218. ]]
  219. do
  220. rvm_ruby_args=("$next_token" "${rvm_ruby_args[@]}")
  221. next_token="${1:-}"
  222. (( $# == 0 )) || shift
  223. done
  224. ;;
  225. rm|remove)
  226. rvm_action="remove"
  227. rvm_remove_flag=1
  228. ;;
  229. rtfm|RTFM|rvmrc|help|inspect|list|ls|info|strings|get|current|docs|alias|rubygems|cleanup|tools|disk-usage|snapshot|repair|migrate|downgrade|upgrade|cron|group|switch|which|config-get|requirements|autolibs|osx-ssl-certs|fix-permissions)
  230. case "$rvm_token" in
  231. (downgrade) rvm_action="upgrade" ;;
  232. (ls) rvm_action="list" ;;
  233. (RTFM) rvm_action="rtfm" ;;
  234. (*) rvm_action="$rvm_token" ;;
  235. esac
  236. rvm_ruby_args=()
  237. __rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@"
  238. rvm_parse_break=1
  239. ;;
  240. user)
  241. rvm_action="tools"
  242. rvm_ruby_args=("$rvm_token" "$next_token" "$@")
  243. rvm_parse_break=1
  244. ;;
  245. load-rvmrc)
  246. rvm_action="rvmrc"
  247. rvm_ruby_args=("load" "$next_token" "$@")
  248. rvm_parse_break=1
  249. ;;
  250. specs|tests)
  251. rvm_action="rake"
  252. rvm_ruby_args=("${rvm_token/%ss/s}")
  253. ;;
  254. export)
  255. if
  256. [[ -n "$next_token" ]]
  257. then
  258. \typeset -a ___args
  259. ___args=( "$next_token" "$@" )
  260. rvm_export_args="${___args[*]}"
  261. rvm_action="export"
  262. rvm_parse_break=1
  263. else
  264. rvm_action="error"
  265. rvm_error_message="rvm export must be followed by a NAME=VALUE argument"
  266. fi
  267. ;;
  268. alt*)
  269. rvm_action="help"
  270. rvm_ruby_args=("alt.md")
  271. rvm_parse_break=1
  272. ;;
  273. wrapper)
  274. rvm_action="wrapper"
  275. rvm_ruby_args=( "$next_token" "$@")
  276. rvm_parse_break=1
  277. ;;
  278. in)
  279. rvm_token="${next_token}"
  280. next_token="${1:-}"
  281. (( $# == 0 )) || shift
  282. export rvm_in_flag="$rvm_token"
  283. __rvm_project_dir_check "$rvm_token" &&
  284. __rvm_rvmrc_tools try_to_read_ruby $rvm_token ||
  285. __rvm_parse_args_error_finding_project_file
  286. ;;
  287. usage)
  288. rvm_action="deprecated"
  289. rvm_error_message="This command has been deprecated. Use ${rvm_notify_clr:-}rvm help${rvm_error_clr:-} instead."
  290. rvm_parse_break=1
  291. ;;
  292. *,*)
  293. rvm_ruby_strings="$rvm_token"
  294. [[ -n "${rvm_action:-""}" ]] ||
  295. rvm_action="ruby" # Not sure if we really want to do this but we'll try it out.
  296. ;;
  297. ${rvm_gemset_separator:-"@"}*)
  298. rvm_action="${rvm_action:-use}"
  299. rvm_gemset_name="${rvm_token#${rvm_gemset_separator:-"@"}}"
  300. rvm_ruby_string="${rvm_ruby_string:-${GEM_HOME##*/}}"
  301. rvm_ruby_string="${rvm_ruby_string%%${rvm_gemset_separator:-"@"}*}"
  302. rvm_ruby_strings="${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
  303. ;;
  304. *${rvm_gemset_separator:-"@"}*)
  305. rvm_verbose_flag=1
  306. rvm_action="${rvm_action:-use}"
  307. rvm_gemset_name="${rvm_token/*${rvm_gemset_separator:-"@"}/}"
  308. rvm_ruby_string="$rvm_token"
  309. rvm_ruby_strings="$rvm_token"
  310. ;;
  311. *+*)
  312. rvm_action="${rvm_action:-use}"
  313. rvm_ruby_alias="${rvm_token/*+/}"
  314. rvm_ruby_string="${rvm_token/+*/}"
  315. rvm_ruby_strings="$rvm_ruby_string"
  316. ;;
  317. *-*|+([0-9]).+([0-9])*)
  318. rvm_verbose_flag=1
  319. rvm_action="${rvm_action:-use}"
  320. rvm_ruby_string="$rvm_token"
  321. rvm_ruby_strings="$rvm_token"
  322. ;;
  323. opal*|jruby*|ree*|macruby*|rbx*|rubinius*|mruby|ironruby*|default*|maglev*|topaz*|truffleruby*|ruby*|system|default|all)
  324. rvm_action="${rvm_action:-use}"
  325. rvm_ruby_interpreter="$rvm_token"
  326. rvm_ruby_string="$rvm_token"
  327. rvm_ruby_strings="$rvm_token"
  328. ;;
  329. kiji*|tcs*|jamesgolick*)
  330. rvm_error_message="The $rvm_token was removed from RVM, use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.1"
  331. rvm_action="error"
  332. ;;
  333. old)
  334. case "${rvm_action:-action-missing}" in
  335. remove)
  336. rvm_ruby_strings="old:${next_token:-}"
  337. next_token="${1:-}"
  338. (( $# == 0 )) || shift
  339. ;;
  340. action-missing)
  341. rvm_error_message="what do you want to do with old rubies? rvm can only remove old rubies."
  342. rvm_action="error"
  343. ;;
  344. *)
  345. rvm_error_message="rvm can not $rvm_action old rubies, rvm can only remove old rubies."
  346. rvm_action="error"
  347. ;;
  348. esac
  349. ;;
  350. *.rb) # we have a specified ruby script
  351. rvm_ruby_args=("$rvm_token")
  352. rvm_ruby_file="$rvm_token"
  353. if
  354. [[ -z "${rvm_action:-""}" || "$rvm_action" == "use" ]]
  355. then
  356. rvm_action="ruby"
  357. fi
  358. ;;
  359. *.gems)
  360. rvm_file_name="${rvm_token}"
  361. ;;
  362. ("")
  363. rvm_action="error"
  364. rvm_error_message="Unrecognized command line argument(s): $@"
  365. ;;
  366. *)
  367. if
  368. [[ "gemset" == "$rvm_action" ]]
  369. then
  370. rvm_gemset_name="${rvm_token/.gems/}"
  371. rvm_file_name="$rvm_gemset_name.gems"
  372. elif
  373. [[ -f "$rvm_rubies_path/$rvm_token" || -L "$rvm_rubies_path/$rvm_token" ]] # ruby || alias
  374. then
  375. rvm_ruby_string=$rvm_token
  376. rvm_ruby_strings="$rvm_token"
  377. rvm_action="${rvm_action:-use}"
  378. elif
  379. [[ -d "$rvm_token" ]] ||
  380. __rvm_project_dir_check "$rvm_token"
  381. then
  382. __rvm_rvmrc_tools try_to_read_ruby $rvm_token ||
  383. __rvm_parse_args_error_finding_project_file
  384. else
  385. rvm_action="error"
  386. rvm_error_message="Unrecognized command line argument: $rvm_token"
  387. fi
  388. ;;
  389. esac
  390. ;;
  391. -*) # Flags
  392. case "$rvm_token" in
  393. -S)
  394. rvm_action="ruby"
  395. rvm_ruby_args=("$rvm_token" "$next_token" "$@")
  396. rvm_parse_break=1
  397. ;;
  398. -e)
  399. rvm_action="ruby"
  400. IFS="\n"
  401. rvm_ruby_args=("$rvm_token" "'$next_token $@'")
  402. IFS=" "
  403. rvm_parse_break=1
  404. ;;
  405. -v|--version)
  406. if [[ -z "$next_token" ]] ; then
  407. rvm_action="version"
  408. else
  409. rvm_ruby_version="$next_token"
  410. next_token="${1:-}"
  411. (( $# == 0 )) || shift
  412. fi
  413. ;;
  414. -n|--name)
  415. rvm_ruby_name="$next_token"
  416. next_token="${1:-}"
  417. (( $# == 0 )) || shift
  418. #TODO: ??? rvm_disable_binary_flag=1
  419. ;;
  420. --branch)
  421. rvm_ruby_repo_branch="$next_token"
  422. next_token="${1:-}"
  423. (( $# == 0 )) || shift
  424. rvm_disable_binary_flag=1
  425. ;;
  426. --tag)
  427. rvm_ruby_repo_tag="$next_token"
  428. next_token="${1:-}"
  429. (( $# == 0 )) || shift
  430. rvm_disable_binary_flag=1
  431. ;;
  432. --repository|--repo|--url)
  433. rvm_ruby_repo_url="$next_token"
  434. next_token="${1:-}"
  435. (( $# == 0 )) || shift
  436. rvm_disable_binary_flag=1
  437. ;;
  438. -r|--remote|--binary|--latest-binary)
  439. rvm_remote_flag=1
  440. if [[ "$rvm_token" == "--latest-binary" ]]
  441. then rvm_fuzzy_flag=1
  442. fi
  443. while
  444. [[ -n "${next_token:-}" ]] &&
  445. [[ "${next_token:-}" == http* ||
  446. "${next_token:-}" == *tar.bz2 ||
  447. "${next_token:-}" == *tar.gz ||
  448. "${next_token:-}" == *":"*
  449. ]]
  450. do
  451. rvm_ruby_args=("${rvm_ruby_args[@]}" "$next_token")
  452. next_token="${1:-}"
  453. (( $# == 0 )) || shift
  454. done
  455. ;;
  456. --ree-options)
  457. if
  458. [[ -n "$next_token" ]]
  459. then
  460. __rvm_custom_separated_array rvm_ree_options , "${next_token}"
  461. next_token="${1:-}"
  462. (( $# == 0 )) || shift
  463. else
  464. rvm_action="error"
  465. rvm_error_message="--ree-options *must* be followed by... well... comma,separated,list,of,options."
  466. fi
  467. ;;
  468. --patches|--patch)
  469. __rvm_custom_separated_array rvm_patch_names , "$next_token"
  470. next_token="${1:-}"
  471. (( $# == 0 )) || shift
  472. rvm_patch_original_pwd="$PWD"
  473. rvm_disable_binary_flag=1
  474. ;;
  475. --arch|--archflags)
  476. rvm_architectures+=( "${next_token#-arch }" )
  477. next_token="${1:-}"
  478. (( $# == 0 )) || shift
  479. rvm_disable_binary_flag=1
  480. ;;
  481. --with-arch=*)
  482. rvm_architectures+=( "${rvm_token#--with-arch=}" )
  483. rvm_disable_binary_flag=1
  484. ;;
  485. --32|--64)
  486. rvm_architectures+=( "${rvm_token#--}" )
  487. rvm_disable_binary_flag=1
  488. ;;
  489. --universal)
  490. rvm_architectures+=( "32" "64" )
  491. rvm_disable_binary_flag=1
  492. ;;
  493. --bin)
  494. rvm_bin_path="$next_token"
  495. next_token="${1:-}"
  496. (( $# == 0 )) || shift
  497. ;;
  498. --rdoc|--yard)
  499. rvm_docs_type="$rvm_token"
  500. rvm_docs_type
  501. ;;
  502. -f|--file)
  503. rvm_action="ruby"
  504. rvm_ruby_file="$next_token"
  505. next_token="${1:-}"
  506. (( $# == 0 )) || shift
  507. ;;
  508. --passenger|--editor)
  509. rvm_warn "NOTE: ${rvm_token} flag is deprecated, RVM now automatically generates wrappers" # 2017-09-21
  510. ;;
  511. -h|--help)
  512. rvm_action=help
  513. ;;
  514. -l|--level)
  515. rvm_ruby_patch_level="p$next_token"
  516. next_token="${1:-}"
  517. (( $# == 0 )) || shift
  518. ;;
  519. --sha|--make|--make-install)
  520. rvm_token=${rvm_token#--}
  521. rvm_token=${rvm_token//-/_}
  522. export "rvm_ruby_${rvm_token}"="$next_token"
  523. next_token="${1:-}"
  524. rvm_disable_binary_flag=1
  525. (( $# == 0 )) || shift
  526. ;;
  527. --nice|--sdk|--autoconf-flags|--proxy)
  528. rvm_token=${rvm_token#--}
  529. rvm_token=${rvm_token//-/_}
  530. export "rvm_${rvm_token}"="$next_token"
  531. next_token="${1:-}"
  532. (( $# == 0 )) || shift
  533. ;;
  534. --disable-llvm|--disable-jit)
  535. rvm_llvm_flag=0
  536. ;;
  537. --enable-llvm|--enable-jit)
  538. rvm_llvm_flag=1
  539. ;;
  540. --install)
  541. rvm_install_on_use_flag=1
  542. ;;
  543. --autolibs=*)
  544. export rvm_autolibs_flag="${rvm_token#*=}"
  545. ;;
  546. --color=*)
  547. rvm_pretty_print_flag=${rvm_token#--color=}
  548. ;;
  549. --pretty)
  550. rvm_pretty_print_flag=auto
  551. ;;
  552. --1.8|--1.9|--2.0|--2.1|--18|--19|--20|--21)
  553. rvm_token=${rvm_token#--}
  554. rvm_token=${rvm_token//\./}
  555. export "rvm_${rvm_token}_flag"=1
  556. rvm_disable_binary_flag=1
  557. ;;
  558. --rvmrc|--versions-conf|--ruby-version)
  559. rvm_token=${rvm_token#--}
  560. rvm_token=${rvm_token//-/_}
  561. export rvm_rvmrc_flag="${rvm_token}"
  562. ;;
  563. --list-missing-packages)
  564. export rvm_list_missing_packages_flag=1
  565. export rvm_quiet_flag=1
  566. ;;
  567. --list-undesired-packages)
  568. export rvm_list_undesired_packages_flag=1
  569. export rvm_quiet_flag=1
  570. ;;
  571. --list-installed-packages)
  572. export rvm_list_installed_packages_flag=1
  573. export rvm_quiet_flag=1
  574. ;;
  575. --list-all-packages)
  576. export rvm_list_missing_packages_flag=1
  577. export rvm_list_undesired_packages_flag=1
  578. export rvm_list_installed_packages_flag=1
  579. export rvm_quiet_flag=1
  580. ;;
  581. --head|--static|--self|--gem|--reconfigure|--default|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--path|--cron|--tail|--delete|--verbose|--import|--sticky|--create|--gems|--docs|--skip-autoreconf|--force-autoconf|--auto-dotfiles|--autoinstall-bundler|--disable-binary|--ignore-gemsets|--skip-gemsets|--debug|--quiet|--silent|--skip-openssl|--fuzzy|--quiet-curl|--skip-pristine|--dynamic-extensions)
  582. rvm_token=${rvm_token#--}
  583. rvm_token=${rvm_token//-/_}
  584. export "rvm_${rvm_token}_flag"=1
  585. ;;
  586. --no-docs)
  587. rvm_token=${rvm_token#--no-}
  588. rvm_token=${rvm_token//-/_}
  589. export "rvm_${rvm_token}_flag"=0
  590. ;;
  591. --auto)
  592. export "rvm_auto_dotfiles_flag"=1
  593. rvm_warn "Warning, --auto is deprecated in favor of --auto-dotfiles."
  594. ;;
  595. --rubygems)
  596. rvm_token=${rvm_token#--}
  597. rvm_token=${rvm_token//-/_}
  598. export "rvm_${rvm_token}_version"="$next_token"
  599. next_token="${1:-}"
  600. (( $# == 0 )) || shift
  601. ;;
  602. --dump-environment|--max-time)
  603. rvm_token=${rvm_token#--}
  604. rvm_token=${rvm_token//-/_}
  605. export "rvm_${rvm_token}_flag"="$next_token"
  606. next_token="${1:-}"
  607. (( $# == 0 )) || shift
  608. ;;
  609. --verify-downloads)
  610. rvm_token=${rvm_token#--}
  611. rvm_token=${rvm_token//-/_}
  612. export "rvm_${rvm_token}_flag_cli"="$next_token"
  613. next_token="${1:-}"
  614. (( $# == 0 )) || shift
  615. ;;
  616. --clang)
  617. export CC=clang
  618. export CXX=clang++
  619. rvm_disable_binary_flag=1
  620. ;;
  621. -M)
  622. if
  623. [[ -n "$next_token" ]]
  624. then
  625. __rvm_custom_separated_array rvm_make_flags , "${next_token}"
  626. next_token="${1:-}"
  627. (( $# == 0 )) || shift
  628. rvm_disable_binary_flag=1
  629. else
  630. rvm_action="error"
  631. rvm_error_message="--make *must* be followed by make flags."
  632. fi
  633. ;;
  634. -j)
  635. if
  636. [[ -n "$next_token" ]]
  637. then
  638. rvm_make_flags+=( -j$next_token )
  639. next_token="${1:-}"
  640. (( $# == 0 )) || shift
  641. else
  642. rvm_action="error"
  643. rvm_error_message="-j *must* be followed by an integer (normally the # of CPU's in your machine)."
  644. fi
  645. ;;
  646. --with-rubies)
  647. rvm_ruby_strings="$next_token"
  648. next_token="${1:-}"
  649. (( $# == 0 )) || shift
  650. ;;
  651. -C|--configure)
  652. if
  653. [[ -n "$next_token" ]]
  654. then
  655. __rvm_custom_separated_array rvm_configure_flags , "${next_token}"
  656. next_token="${1:-}"
  657. (( $# == 0 )) || shift
  658. rvm_disable_binary_flag=1
  659. else
  660. rvm_action="error"
  661. rvm_error_message="--configure *must* be followed by configure flags."
  662. fi
  663. ;;
  664. -E|--env)
  665. if
  666. [[ -n "$next_token" ]]
  667. then
  668. __rvm_custom_separated_array rvm_configure_env , "${next_token}"
  669. next_token="${1:-}"
  670. (( $# == 0 )) || shift
  671. rvm_disable_binary_flag=1
  672. else
  673. rvm_action="error"
  674. rvm_error_message="--configure *must* be followed by configure flags."
  675. fi
  676. ;;
  677. --movable)
  678. rvm_movable_flag=1
  679. rvm_disable_binary_flag=1
  680. ;;
  681. --with-*|--without-*|--enable-*|--disable-*)
  682. rvm_configure_flags+=( "$rvm_token" )
  683. rvm_disable_binary_flag=1
  684. ;;
  685. --trace)
  686. export rvm_trace_flag=1
  687. # duplication marker jkdfkdfngjdjkfngjkdfngjkd
  688. if [[ -n "${BASH_VERSION:-}" ]]
  689. then export PS4="+ \$(__rvm_date \"+%s.%N\" 2>/dev/null) \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
  690. elif [[ -n "${ZSH_VERSION:-}" ]]
  691. then export PS4="+ %* %F{red}%x:%I %F{green}%N:%i%F{white} %_"
  692. fi
  693. set -o xtrace
  694. ;;
  695. --)
  696. if [[ "${rvm_action}" == *install ]]
  697. then rvm_configure_flags+=( "$next_token" "$@" )
  698. else rvm_ruby_args=( "$next_token" "$@" )
  699. fi
  700. rvm_disable_binary_flag=1
  701. rvm_parse_break=1
  702. ;;
  703. *)
  704. rvm_action="error"
  705. rvm_error_message="Unrecognized command line flag: '$rvm_token'"
  706. esac
  707. ;;
  708. *)
  709. if
  710. [[ -d "$rvm_token" ]] ||
  711. __rvm_project_dir_check "$rvm_token"
  712. then
  713. __rvm_rvmrc_tools try_to_read_ruby "$rvm_token" ||
  714. __rvm_parse_args_error_finding_project_file
  715. else
  716. rvm_action="error"
  717. rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'"
  718. fi
  719. ;;
  720. esac
  721. if [[ -z "${rvm_action:-""}" && -n "${rvm_ruby_string:-""}" ]]
  722. then rvm_action="use"
  723. fi
  724. if [[ "error" == "${rvm_action:-""}" || ${rvm_parse_break:-0} -eq 1 || -n "${rvm_error_message:-""}" ]]
  725. then break
  726. fi
  727. done
  728. : rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:
  729. if
  730. [[ -n "${rvm_error_message:-""}" ]]
  731. then
  732. if
  733. [[ "${rvm_action}" == "deprecated" ]]
  734. then
  735. rvm_error "$rvm_error_message"
  736. else
  737. rvm_error "$rvm_error_message"
  738. rvm_out "Run \`rvm help\` to see usage information"
  739. fi
  740. unset rvm_error_message
  741. return 1
  742. fi
  743. }
  744. rvm()
  745. {
  746. \typeset result current_result
  747. rvm_ruby_args=()
  748. __rvm_teardown_if_broken
  749. __rvm_cli_posix_check || return $?
  750. __rvm_cli_load_rvmrc || return $?
  751. __rvm_cli_version_check "$@" || return $?
  752. __rvm_initialize
  753. __rvm_path_match_gem_home_check
  754. __rvm_setup
  755. __rvm_cli_autoupdate "$@" || return $?
  756. next_token="$1"
  757. (( $# == 0 )) || shift
  758. __rvm_parse_args "$@"
  759. result=$?
  760. : rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:
  761. (( ${rvm_trace_flag:-0} == 0 )) || set -o xtrace
  762. (( result )) ||
  763. case "${rvm_action:=help}" in
  764. use)
  765. if rvm_is_a_shell_function
  766. then __rvm_use && __rvm_use_ruby_warnings
  767. fi
  768. ;;
  769. switch)
  770. if rvm_is_a_shell_function
  771. then __rvm_switch "${rvm_ruby_args[@]}"
  772. fi
  773. ;;
  774. inspect|strings|version|remote_version)
  775. __rvm_${rvm_action}
  776. ;;
  777. ls|list)
  778. "$rvm_scripts_path/list" "${rvm_ruby_args[@]}"
  779. ;;
  780. # TODO: Make debug run in the current environment, issues with not exported vars.
  781. debug)
  782. rvm_is_not_a_shell_function="${rvm_is_not_a_shell_function}" "$rvm_scripts_path/info" '' debug
  783. ;;
  784. info)
  785. rvm_is_not_a_shell_function="${rvm_is_not_a_shell_function}" "$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
  786. ;;
  787. reset)
  788. source "$rvm_scripts_path/functions/${rvm_action}"
  789. __rvm_${rvm_action}
  790. ;;
  791. update)
  792. printf "%b" "ERROR: rvm update has been removed. Try 'rvm get head' or see the 'rvm get' and rvm 'rubygems' CLI API instead\n"
  793. ;;
  794. implode|seppuku)
  795. source "$rvm_scripts_path/functions/implode"
  796. __rvm_implode
  797. ;;
  798. get)
  799. next_token="${1:-}"
  800. (( $# == 0 )) || shift
  801. [[ "$next_token" == "${rvm_action}" ]] && shift
  802. __rvm_cli_rvm_get "${rvm_ruby_args[@]}"
  803. ;;
  804. current)
  805. __rvm_env_string
  806. ;;
  807. help|rtfm|env|list|monitor|notes|pkg|requirements)
  808. next_token="${1:-}"
  809. (( $# == 0 )) || shift
  810. if (( $# )) && [[ "$next_token" == "${rvm_action}" ]] #TODO why is this check here ???
  811. then shift
  812. fi
  813. "$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
  814. ;;
  815. cleanup|tools|snapshot|disk-usage|repair|alias|docs|rubygems|migrate|cron|group|wrapper)
  816. "$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
  817. ;;
  818. upgrade)
  819. # file action params
  820. __rvm_fix_selected_ruby \
  821. __rvm_run_wrapper "$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
  822. ;;
  823. autolibs|osx-ssl-certs|fix-permissions)
  824. # file action params
  825. __rvm_run_wrapper "$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
  826. ;;
  827. do)
  828. old_rvm_ruby_string=${rvm_ruby_string:-}
  829. unset rvm_ruby_string
  830. export rvm_ruby_strings rvm_in_flag
  831. result=0
  832. # run in a subprocess only when a function, when called via PATH just replace the process
  833. if rvm_is_a_shell_function no_warning
  834. then "$rvm_scripts_path/set" "$rvm_action" "${rvm_ruby_args[@]}" || result=$?
  835. else exec "$rvm_scripts_path/set" "$rvm_action" "${rvm_ruby_args[@]}" || result=$?
  836. fi
  837. # Restore the state pre-sets.
  838. [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
  839. unset old_rvm_ruby_string
  840. ;;
  841. rvmrc)
  842. __rvm_rvmrc_tools "${rvm_ruby_args[@]}"
  843. ;;
  844. config-get)
  845. \typeset __ruby __var
  846. __ruby=$( __rvm_which ruby )
  847. for __var in "${rvm_ruby_args[@]}"
  848. do
  849. __rvm_ruby_config_get "${__var}" "${__ruby}"
  850. done
  851. ;;
  852. gemset_use)
  853. if rvm_is_a_shell_function
  854. then __rvm_gemset_use
  855. fi
  856. ;;
  857. gemset)
  858. export rvm_ruby_strings
  859. "$rvm_scripts_path/gemsets" "${rvm_ruby_args[@]}"
  860. result=$?
  861. rvm_ruby_strings=""
  862. if
  863. rvm_is_a_shell_function no_warning
  864. then
  865. # Clear the gemset.
  866. if
  867. [[ ${rvm_delete_flag:-0} -eq 1 ]]
  868. then
  869. if
  870. [[ "${GEM_HOME:-""}" == "${GEM_HOME%%${rvm_gemset_separator:-@}*}${rvm_gemset_separator:-@}${rvm_gemset_name}" ]]
  871. then
  872. rvm_delete_flag=0
  873. __rvm_use "@default"
  874. fi
  875. unset gem_prefix
  876. elif
  877. [[ "${rvm_ruby_args[*]}" == rename* ]]
  878. then
  879. \typeset _command _from _to
  880. read _command _from _to <<<"${rvm_ruby_args[*]}"
  881. if
  882. [[ "${GEM_HOME:-""}" == "${GEM_HOME%%${rvm_gemset_separator:-@}*}${rvm_gemset_separator:-@}${_from}" ]]
  883. then
  884. __rvm_use "@${_to}"
  885. fi
  886. fi
  887. fi
  888. ;;
  889. reload)
  890. rvm_reload_flag=1
  891. ;;
  892. tests|specs)
  893. rvm_action="rake"
  894. __rvm_do
  895. ;;
  896. remove)
  897. export rvm_path
  898. if [[ -n "${rvm_ruby_strings}" ]]
  899. then __rvm_run_wrapper manage "$rvm_action" "${rvm_ruby_strings//*-- }"
  900. else __rvm_run_wrapper manage "$rvm_action"
  901. fi
  902. __rvm_use default
  903. ;;
  904. fetch|uninstall|reinstall)
  905. export rvm_path
  906. if [[ -n "${rvm_ruby_strings}" ]]
  907. then __rvm_run_wrapper manage "$rvm_action" "${rvm_ruby_strings//*-- }"
  908. else __rvm_run_wrapper manage "$rvm_action"
  909. fi
  910. ;;
  911. try_install|install)
  912. export rvm_path
  913. __rvm_cli_install_ruby "${rvm_ruby_strings}"
  914. ;;
  915. automount)
  916. if [[ -n "$rvm_ruby_string" ]]
  917. then rvm_ruby_args=( "$rvm_ruby_string" "${rvm_ruby_args[@]}" )
  918. fi
  919. "${rvm_scripts_path}/mount" "$rvm_action" "${rvm_ruby_args[@]}"
  920. ;;
  921. mount|prepare)
  922. if [[ -n "$rvm_ruby_string" ]]
  923. then rvm_ruby_args=( "$rvm_ruby_string" "${rvm_ruby_args[@]}" )
  924. fi
  925. "${rvm_scripts_path}/$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
  926. ;;
  927. export)
  928. __rvm_export "$rvm_export_args"
  929. ;;
  930. unexport)
  931. __rvm_unset_exports
  932. ;;
  933. error)
  934. false
  935. ;;
  936. which)
  937. __rvm_which "${rvm_ruby_args[@]}"
  938. ;;
  939. *)
  940. rvm_error "unknown action '$rvm_action'"
  941. false # result
  942. ;;
  943. esac
  944. current_result=$? # Use the result of first found error
  945. (( result )) || result=${current_result}
  946. (( result )) ||
  947. case "$rvm_action" in
  948. reinstall|try_install|install)
  949. if
  950. [[ -n "${rvm_ruby_string}" ]]
  951. rvm_is_a_shell_function no_warning
  952. then
  953. if [[ -e "${rvm_environments_path}/default" ]]
  954. then rvm_verbose_flag=0 __rvm_use
  955. else rvm_verbose_flag=0 rvm_default_flag=1 __rvm_use
  956. fi
  957. fi
  958. ;;
  959. esac
  960. current_result=$? # Use the result of first found error
  961. (( result )) || result=${current_result}
  962. \typeset __local_rvm_trace_flag
  963. __local_rvm_trace_flag=${rvm_trace_flag:-0}
  964. __rvm_cli_autoreload
  965. if (( __local_rvm_trace_flag > 0 ))
  966. then
  967. set +o verbose
  968. set +o xtrace
  969. [[ -n "${ZSH_VERSION:-""}" ]] || set +o errtrace
  970. fi
  971. return ${result:-0}
  972. }