From e5d1b3df4de2ebaa6200619a7ccb872279ce0d81 Mon Sep 17 00:00:00 2001 From: mizou04 <1mizou1@gmail.com> Date: Tue, 5 Sep 2023 19:08:38 +0100 Subject: [PATCH] warn user that installation with --system flag will fail if she's not root --- share/ruby-install/ruby-install.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/share/ruby-install/ruby-install.sh b/share/ruby-install/ruby-install.sh index 83e634a5..e04df4be 100644 --- a/share/ruby-install/ruby-install.sh +++ b/share/ruby-install/ruby-install.sh @@ -105,6 +105,20 @@ function parse_ruby() fi } +# +#Called when selecting --system flag +# +function ensure_is_sudo() { + local warn_c="\e[1;33;1m" #set color + local reset_c="\e[0m" #unset color + if [[ UID != 0 ]] + then + echo -e "${warn_c}you may need permissions before proceeding${reset_c}" + exit + fi +} + + # # Parses command-line options for ruby-install. # @@ -123,6 +137,7 @@ function parse_options() shift 2 ;; --system) + ensure_is_sudo install_dir="$system_dir" shift 1 ;;