group 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. source "$rvm_scripts_path/base"
  3. source "$rvm_scripts_path/functions/group"
  4. source "$rvm_scripts_path/functions/utility"
  5. source "$rvm_scripts_path/functions/version"
  6. group_add()
  7. {
  8. \typeset user group
  9. group="$1"
  10. shift
  11. for user in "$@"
  12. do
  13. if
  14. __rvm_is_user_in_group "$group" "$user"
  15. then
  16. echo "User '$user' already in the group '$group'"
  17. else
  18. echo "Adding user '$user' to the group '$group'"
  19. __rvm_add_user_to_group "$group" "$user"
  20. fi
  21. done
  22. }
  23. group_create()
  24. {
  25. \typeset -a _params
  26. _params=( "${1:-$rvm_group_name}" )
  27. shift
  28. if
  29. (( $# ))
  30. then
  31. _params+=( "$1" )
  32. else
  33. if [[ "$1" == "${rvm_group_name}" && -n "${rvm_group_id:-}" ]]
  34. then _params+=( "${rvm_group_id:-}" )
  35. fi
  36. fi
  37. __rvm_create_group "${_params[@]}"
  38. }
  39. action="$1"
  40. shift
  41. true "${rvm_group_name:=rvm}"
  42. case "$action" in
  43. add|create|help)
  44. group_$action "$@"
  45. ;;
  46. *)
  47. rvm_help group "$@"
  48. false
  49. ;;
  50. esac