github - How do if fix theses syntax errors with this bash script - Stack Overflow

时间: 2025-01-06 admin 业界

I've been searching the web to find a Bash dialog script for my project I've found one and I'm trying to edit the script so when you execute the script, the script will prompt the user what option you want to select, once the user has selected that option it will execute a script that runs another dialog box and prompts the user more options to select a repository, once the user selected a repository it will execute a command using curl to run a Bash script that checks what distro you are using and install it using curl and then use curl to install docker and runs a Bash script that runs the compose.yml file and exits after the compose file is finished. The bash scripts are from the Github repository Dialog.

The blockquote text will be added to the script in the future once the syntax errors are fixed

Bash Script file name: "dialog.sh"

#!/bin/bash
echo "Installing Required packages curl git"
sudo apt install -y git curl
cd ~/
echo -e "git cloning /"
cmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Install Docker" off    # any option can be set to default to "on"        
        (2 "LinuxServer" off
        (3 "Other Options" off
        (4 "Exit" off
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
for choice in $choices
do
    case $choice in
        1)  echo -e "Installing ${BCyan}Docker"
            curl -fsSL / | bash
            echo "Done installing Docker"
            ;;
        
            
        2)
            echo "You've selected LinuxServer"
            curl -fsSL         
.sh | bash      
            ;;
        3)
            echo "Youve Pick other options"
            ;;
        4)
            echo "Exiting"
            exit :1
            ;;
    esac
done

when you execute the bash script using this command "bash dialog.sh" you get the following error

dialog.sh: line 15 syntax error near unexpected token `)' 
dialog.sh: line 15: `2)' 

when you execute test.sh using this command "bash test.sh" you get the following error

test.sh: line 8: syntax error near unexpected token `(' 
test.sh  line 8: `      (2 "LinuxServer off'
test.sh  line 8: syntax error: unexpected end of file

NOTE: The blue highlighted text "test.sh" is the url to the raw format of the script