Avoid gsub()s in jq and use sed instead. - gophercgis - Collection of gopher CGI/DCGI for geomyidae
 (HTM) hg clone https://bitbucket.org/iamleot/gophercgis
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) changeset 95f1bf9a52be751ba4dc6140bc86c75edc006685
 (DIR) parent 7cf071db351fa8c703f578b779f0b80653a914b9
 (HTM) Author: Leonardo Taccari <iamleot@gmail.com>
       Date:   Mon, 13 Aug 2018 02:06:30 
       
       Avoid gsub()s in jq and use sed instead.
       
       This simplify a bit the jq logic.
       
       Diffstat:
        reddit/c.cgi |  9 ++++++---
        1 files changed, 6 insertions(+), 3 deletions(-)
       ---
       diff -r 7cf071db351f -r 95f1bf9a52be reddit/c.cgi
       --- a/reddit/c.cgi      Mon Aug 13 01:59:40 2018 +0200
       +++ b/reddit/c.cgi      Mon Aug 13 02:06:30 2018 +0200
       @@ -20,14 +20,17 @@
               "Comments: \(.num_comments)",
               "",
               if .selftext != "" then
       -               "\(.selftext | gsub("&gt;"; ">") | gsub("&amp;"; "&"))",
       +               .selftext,
                       ""
               else
                       empty
               end ),
        ( .[1] | .. | select(.kind? == "t1") | .data |
               "\(.author)   \(.score)   \(.created_utc | strftime("%F %H:%M"))",
       -       "\(.body | gsub("&gt;"; ">") | gsub("&amp;"; "&"))",
       +       .body,
               "",
               "" )
       -'
       +' | sed \
       +    -e 's/\&gt;/>/g' \
       +    -e 's/\&lt;/</g' \
       +    -e 's/\&amp;/\&/g'