Make my set proxy script better
Messy formatting

The first thing I noticed about this script is the messy formatting.
Poorly formatted code is hard to read and maintain.

Extract complex conditions to helper functions

The code has many complex conditions.
It would be more readable if you extracted them into helper functions.

For example, instead of this:


  if [[ $proxy =~ ^https:// &amp;&amp; $proxy =~ :[0-9]{1,5}$ ]]; then
    # ...



You could introduce this helper function:

isHttpsWithPort() {
  [[ $proxy =~ ^https:// &amp;&amp; $proxy =~ :[0-9]{1,5}$ ]]
}


And then use it with:

if isHttpsWithPort; then
  # ...


I recommend to change all complex conditions like that,
and the code will be more readable,
thanks to self-explanatory names of the functions.

Make yesno return success or failure

After calling the yesno function you check the value of REPLY.
This is not very ergonomic.
You could make yesno return success for "yes" and failure for "no":

yesno() {
  while read -n1 -r -p "[y/n/QUIT] &gt; "; do
    case $REPLY in
      y) return 0;;
      n) return 1;;
      q) echo; echo; exit 1;;
      *) printf "\nERROR - Invalid response, please enter Yes OR No.\n";;
    esac
  done
}


When written this way,
instead of this:


    yesno
    if [[ $REPLY == "n" ]]; then
      startover
    fi



You could simplify to:

yesno || startover


Similarly, instead of this:


  yesno
  if [[ $REPLY == "y" ]]; then



You could write:

if yesno; then


Loop not looping

The main while loop doesn't actually loop, so it should be removed:


while true; do
  # ...
  break
done