So I have the following standard script:
#!/bin/bash
PS3='Please enter your choice: '
options=("option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1")
echo "you chose choice 1"
;;
"Option 2")
echo "you chose choice 2"
;;
"Option 3")
echo "you chose choice 3"
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
But when I run the script through SSH and choose the Quit option, the SSH exits too. What might cause the problem? I only want to exit the script and to continue work in SSH.
Well the problem was in .bash_aliases file which I discussed below. I was put exec before the script. When I remove it and run the command, everything was OK.
ssh user@ip commandit will execute and exitsourceto execute script or usereturnstatement instead ofexit