Skip to content

The IP regexp not working on MacOS Sequoia 15.4 #33

@jarppiko

Description

@jarppiko

Hello!

Thanks for the script. The REIP regular expression is not working on MacOS 15.4's Bash.

I had to edit the script as it follows:

# Regexp for numbers 1-255
RX='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' 

### Get external ip from https://checkip.amazonaws.com
if [ "${what_ip}" == "external" ]; then
  ip=$(curl -4 -s -X GET https://checkip.amazonaws.com --max-time 10)
  if [ -z "$ip" ]; then
    echo "Error! Can't get external ip from https://checkip.amazonaws.com"
    exit 0
  fi
 # Changed below
  if ! [[ "$ip" =~ ^$RX\.$RX\.$RX\.$RX$ ]]; then
    echo "Error! IP Address returned was invalid!"
    exit 0
  fi
  echo "==> External IP is: $ip"
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions