diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2013-07-25 00:08:09 +0200 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2013-07-25 00:08:09 +0200 |
commit | 906c6daa8a1ab95b3e169b09a925816ebce4831c (patch) | |
tree | 3074e2aefcd98a15f6cf322646a270a8d44c0300 /src/lib | |
parent | 20c66d6499f22adad6c1dae854a627f061c5fbcb (diff) | |
parent | 7d081a227528201ed65b8bab9ec07ccd8dfc1162 (diff) | |
download | netctl-906c6daa8a1ab95b3e169b09a925816ebce4831c.tar.gz netctl-906c6daa8a1ab95b3e169b09a925816ebce4831c.tar.xz |
Merge branch 'master' of git://github.com/gandro/netctl into gandro-master
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/wpa | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/wpa b/src/lib/wpa index b80c54d..d79fdbe 100644 --- a/src/lib/wpa +++ b/src/lib/wpa @@ -166,6 +166,24 @@ wpa_quote() { fi } +## Unquotes a string, i.e. returned from wpa_cli +## Quoted: "string" -> string +## Non-Quoted: string -> string +## Hex: 737472696e67 -> string +wpa_unquote() { + local string="$1" + if [[ ${string:0:1} == '"' && ${string:(-1)} == '"' ]]; then + printf "%s" "${string:1:-1}" + elif [[ "$string" =~ ^([[:xdigit:]]{2})+$ ]]; then + while [[ -n "$string" ]]; do + printf "\x"${string:0:2} + string=${string:2} + done + else + printf "%s" "${string}" + fi +} + ## Create a configuration file for wpa_supplicant without any network blocks # $1: interface name wpa_make_config_file() { |