From dcfa2834f5451d12fbce1a000473db7f824fa8c2 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Mon, 2 Sep 2024 02:54:11 +0200 Subject: [PATCH] Update sandboxes.am: refactoring --- modules/sandboxes.am | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/sandboxes.am b/modules/sandboxes.am index 95b12e631..c4b526791 100644 --- a/modules/sandboxes.am +++ b/modules/sandboxes.am @@ -64,7 +64,7 @@ _check_aisap() { return 1 elif ! command -v aisap 1>/dev/null; then printf '\n%s\n\n' " Error: You need aisap for this script work" - read -p " ◆ DO YOU WISH TO INSTALL AISAP? Install size <5 MiB? (Y/n) " yn + read -r -p " ◆ DO YOU WISH TO INSTALL AISAP? Install size <5 MiB? (Y/n) " yn if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then echo " OPERATION ABORTED!" return 1 @@ -177,14 +177,14 @@ _generate_sandbox_script() { _configure_dirs_access() { printf '\033[33m\n' - read -p " Do you want configure access to directories? (Y/n): " yn + read -r -p " Do you want configure access to directories? (Y/n): " yn if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then return 0 fi printf '\033[36m' for DIR in DESKTOP DOCUMENTS DOWNLOAD GAMES MUSIC PICTURES VIDEOS; do eval XDG_DIR=\$$DIR - read -p " Allow $1 access to \"$XDG_DIR\"? (y/N) " yn + read -r -p " Allow $1 access to \"$XDG_DIR\"? (y/N) " yn if echo "$yn" | grep -i '^y' >/dev/null 2>&1; then tmpscript=$(echo "$tmpscript" \ | sed "s#--rm-file \"\$$DIR\"#--add-file \"\$$DIR\":rw#g" ) @@ -192,18 +192,18 @@ _configure_dirs_access() { done sleep 0.5 printf '\033[31m' - read -p " Allow $1 access to a specific directory? (y/N) " yn + read -r -p " Allow $1 access to a specific directory? (y/N) " yn if echo "$yn" | grep -i '^y' >/dev/null 2>&1; then echo " WARNING: Giving access to all of $HOME or / and similar is not safe" echo " Also aisap might not let $1 start when such paths are given" printf '\033[33m%s\n' " Type the path to the directory" - read -p " Example: /media/external-drive or ~/Backups: " NEWDIR + read -r -p " Example: /media/external-drive or ~/Backups: " NEWDIR case "$NEWDIR" in - '$HOME'|'$HOME/'|"$HOME"|"$HOME/"|"/"|"~"|"~/"|"/home"|"/home/"|\ - "$DATADIR"|'$XDG_DATA_HOME'|"$CONFIGDIR"|'$XDG_CONFIG_HOME'|"$BINDIR") + "\$HOME"|"\$HOME/"|"$HOME"|"$HOME/"|"/"|"~"|~/|"/home"|"/home/"|\ + "$DATADIR"|"\$XDG_DATA_HOME"|"$CONFIGDIR"|"\$XDG_CONFIG_HOME"|"$BINDIR") notify-send -u critical "DO YOU WANT THE FBI TO GET YA?" printf '\033[31m\n' - read -p " SPOOKY LOCATION! ARE YOU SURE? IF SO TYPE \"YES\": " YES + read -r -p " SPOOKY LOCATION! ARE YOU SURE? IF SO TYPE \"YES\": " YES [ "$YES" != "YES" ] && echo " That's not \"YES\", aborting" && return 1 ;; '') @@ -231,7 +231,7 @@ _install_sandbox_script() { printf '\033[32m\n%s\n\033[0m' " \"$1\" successfully sandboxed!" printf '\n%s\n' " $1 will be sandboxed in \"$SANDBOXDIR\"" printf '%s\n\n' " once launched" - printf '%s\n' ' Set the $SANDBOXDIR env variable to move the location' + printf '%s\n' " Set the \$SANDBOXDIR env variable to move the location" printf '\n%s' ' Use ' printf '\033[33m%s' '--disable-sandbox' printf '\033[0m%s\033[33m\n' " to revert the changes, in this case that is:" @@ -243,36 +243,36 @@ _install_sandbox_script() { [ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1 case "$1" in '--sandbox') - shift - for arg in ${@}; do - _check_appimage "${@}" && _check_aisap "${@}" \ - && _generate_sandbox_script "${@}" \ - && _configure_dirs_access "${@}" \ - && _install_sandbox_script "${@}" + ARGS="$(echo "$@" | cut -f2- -d ' ')" + for arg in $ARGS; do + _check_appimage "$arg" && _check_aisap "$arg" \ + && _generate_sandbox_script "$arg" \ + && _configure_dirs_access "$arg" \ + && _install_sandbox_script "$arg" shift done ;; '--disable-sandbox') - shift - for arg in ${@}; do - _disable_sandbox "${@}" + ARGS="$(echo "$@" | cut -f2- -d ' ')" + for arg in $ARGS; do + _disable_sandbox "$arg" shift done ;; '-H'|'--home') - shift - for arg in ${@}; do - _check_appimage "${@}" && _home "${@}" + ARGS="$(echo "$@" | cut -f2- -d ' ')" + for arg in $ARGS; do + _check_appimage "$arg" && _home "$arg" shift done ;; '-C'|'--config') - shift - for arg in ${@}; do - _check_appimage "${@}" && _config "${@}" + ARGS="$(echo "$@" | cut -f2- -d ' ')" + for arg in $ARGS; do + _check_appimage "$arg" && _config "$arg" shift done ;;