Browse Source

Try awk instead for \n replacements

Jeremy Knope 7 years ago
parent
commit
8e6cf669ad
1 changed files with 2 additions and 4 deletions
  1. 2 4
      dnsapi/dns_linode.sh

+ 2 - 4
dnsapi/dns_linode.sh

@@ -68,8 +68,7 @@ dns_linode_rm() {
   _parameters="&DomainID=$_domain_id"
   _parameters="&DomainID=$_domain_id"
 
 
   if _rest GET "domain.resource.list" "$_parameters" && [ -n "$response" ]; then
   if _rest GET "domain.resource.list" "$_parameters" && [ -n "$response" ]; then
-    response="$(echo "$response" | tr -d "\n" | sed 's/{/\
-&/g')"
+    response="$(echo "$response" | tr -d "\n" | awk '{ gsub("{","\n{",$1); print $1 }')"
 
 
     resource="$(echo "$response" | _egrep_o "{.*\"NAME\":\s*\"$_sub_domain\".*}")"
     resource="$(echo "$response" | _egrep_o "{.*\"NAME\":\s*\"$_sub_domain\".*}")"
     if [ "$resource" ]; then
     if [ "$resource" ]; then
@@ -129,8 +128,7 @@ _get_root() {
   p=1
   p=1
 
 
   if _rest GET "domain.list"; then
   if _rest GET "domain.list"; then
-    response="$(echo "$response" | tr -d "\n" | sed 's/{/\
-&/g')"
+    response="$(echo "$response" | tr -d "\n" | awk '{ gsub("{","\n{",$1); print $1 }')"
     while true; do
     while true; do
       h=$(printf "%s" "$domain" | cut -d . -f $i-100)
       h=$(printf "%s" "$domain" | cut -d . -f $i-100)
       _debug h "$h"
       _debug h "$h"