Skip to content

Commit

Permalink
Merge pull request #84 from marmelab/set-universal-ip-command
Browse files Browse the repository at this point in the history
fix: replace grep -P commands - Closes #83 #63
  • Loading branch information
JulienMattiussi authored Jul 24, 2024
2 parents f199983 + d4da871 commit f3ffbdf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bash/getHostIP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ if command -v ip 1> /dev/null;
then
if ip -4 addr show docker0 > /dev/null 2>&1 # Docker0 is network for docker under linux and OSX
then
printf $(ip -4 addr show docker0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
printf $(ip -4 addr show docker0 | grep -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | head -1)
else
printf $(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') # eth0 is network for docker under wsl
printf $(ip -4 addr show eth0 | grep -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | head -1) # eth0 is network for docker under wsl
fi
else
printf $(ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{ print $2 }' | head -1 | sed -n 's/[^0-9]*\([0-9\.]*\)/\1/p')
Expand Down

0 comments on commit f3ffbdf

Please sign in to comment.