diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-16 20:10:25 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-17 05:55:03 +0100 |
commit | a3b104108ebd06c2585d8bf4cbea1ed51c955c5e (patch) | |
tree | 18bdcdff754ce7973278dab5389c7f3b44ff39d4 /src/tools/wg-quick.bash | |
parent | external-tests: update go version (diff) | |
download | wireguard-monolithic-historical-a3b104108ebd06c2585d8bf4cbea1ed51c955c5e.tar.xz wireguard-monolithic-historical-a3b104108ebd06c2585d8bf4cbea1ed51c955c5e.zip |
tools: allow in-line comments
Diffstat (limited to 'src/tools/wg-quick.bash')
-rwxr-xr-x | src/tools/wg-quick.bash | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash index 80921bf..af72f7d 100755 --- a/src/tools/wg-quick.bash +++ b/src/tools/wg-quick.bash @@ -27,7 +27,7 @@ PROGRAM="${0##*/}" ARGS=( "$@" ) parse_options() { - local interface_section=0 line key value + local interface_section=0 line key value stripped CONFIG_FILE="$1" [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf" [[ -e $CONFIG_FILE ]] || die "\`$CONFIG_FILE' does not exist" @@ -37,8 +37,9 @@ parse_options() { INTERFACE="${BASH_REMATCH[2]}" shopt -s nocasematch while read -r line || [[ -n $line ]]; do - key="${line%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}" - value="${line#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}" + stripped="${line%%\#*}" + key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}" + value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}" [[ $key == "["* ]] && interface_section=0 [[ $key == "[Interface]" ]] && interface_section=1 if [[ $interface_section -eq 1 ]]; then |