Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly throw errors when an invalid option is passed #1560

Merged
merged 2 commits into from
Feb 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions quickget
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function error_specify_os() {
}

function os_supported() {
if [[ ! "$(os_support)" =~ ${OS} ]]; then
if [[ ! " $(os_support) " =~ \ "${OS}"\ ]]; then
echo -e "ERROR! ${OS} is not a supported OS.\n"
os_support | fmt -w 80
exit 1
Expand Down Expand Up @@ -184,7 +184,7 @@ function error_specify_release() {
}

function error_not_supported_release() {
if [[ ! "${RELEASES[*]}" =~ ${RELEASE} ]]; then
if [[ ! " ${RELEASES[*]} " =~ \ "${RELEASE}"\ ]]; then
echo -e "ERROR! ${DISPLAY_NAME} ${RELEASE} is not a supported release.\n"
echo -n ' - Supported releases: '
"releases_${OS}"
Expand All @@ -208,6 +208,17 @@ function error_not_supported_argument() {
exit 1
}

function is_valid_language() {
local I18N=""
local PASSED_I18N="${1}"
for I18N in "${I18NS[@]}"; do
if [[ "${I18N}" == "${PASSED_I18N}" ]]; then
return 0
fi
done
return 1
}

function handle_missing() {
# Handle odd missing Fedora combinations
case "${OS}" in
Expand Down Expand Up @@ -1769,7 +1780,7 @@ function get_elementary() {
case ${RELEASE} in
7.0) STAMP="20230129rc";;
7.1) STAMP="20230926rc";;
8.0) STAMP="20241122rc";;
8.0) STAMP="20241122rc";;
esac
local ISO="elementaryos-${RELEASE}-stable.${STAMP}.iso"
local URL="https://ams3.dl.elementary.io/download"
Expand Down Expand Up @@ -3566,7 +3577,7 @@ if [ -n "${2}" ]; then
EDITIONS=("$(editions_"${OS}")")
if [ -n "${3}" ]; then
EDITION="${3}"
if [[ ! "${EDITIONS[*]}" = *"${EDITION}"* ]]; then
if [[ ! " ${EDITIONS[*]} " = \ "${EDITION}"\ ]]; then
echo -e "ERROR! ${EDITION} is not a supported $(pretty_name "${OS}") edition\n"
echo -n ' - Supported editions: '
for EDITION in "${EDITIONS[@]}"; do
Expand Down Expand Up @@ -3602,7 +3613,7 @@ if [ -n "${2}" ]; then
"languages_${OS}"
if [ -n "${3}" ]; then
I18N="${3}"
if [[ ! "${I18NS[*]}" = *"${I18N}"* ]]; then
if ! is_valid_language "${I18N}"; then
error_not_supported_lang
fi
VM_PATH="$(echo "${OS}-${RELEASE}-${I18N// /-}" | tr -d '()')"
Expand Down