diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-06-17 18:55:14 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-06-17 18:55:14 +0200 |
commit | 0e6959e1fc8bfc0894fef5ca730f000cd10c7818 (patch) | |
tree | 4c0910ba39607036df8341b56f6abc2c3d27f805 | |
parent | 4f6b78155e6a4ab1128b81b936e451202c76eedd (diff) |
Use bash regex instead of sed -rv1.4.3
sed -r is not supported on OS X and using bash actually makes the code
easier.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | fb.in | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -247,8 +247,9 @@ read_string() { } id_from_arg() { - if printf "%s" "$1" | grep -qE "^https?://"; then - printf "%s" "$1" | sed -r 's/https?:\/\/[^\/]+\/([^\/]+).*/\1/' + local regex="https?:\/\/[^\/]+\/([^\/]+).*" + if [[ $1 =~ $regex ]]; then + printf "%s" "${BASH_REMATCH[1]}" else printf "%s" "$1" fi |