Skip to content

Add pretty print options #12

Description

@dol

It would be nice of the resulting bash commands could be pretty printed.

E.g.:

(trap "kill 0" SIGINT; export LC_ALL=C; curl -s -N "http://some.tld/data" | tail -n+2|awk -F',' '{q=0; o=""; for (i=1; i<=NF; i+=1) {if (q) o=o","$i; else o=o"\t"$i; if ($i == "\"") q=1-q; else{ if (substr($i,length($i),1)=="\"") q=0; else if (substr($i,1,1)=="\"") q=1; }}gsub(/\"/,"",o); print substr(o,2)}'|cut -d $'\t' -f1,3,8|awk -F '\t' '($3 > 0.97) {print}'|awk -F '\t' '{print $1"\t"$2}')

Pretty print version:

(
    trap "kill 0" SIGINT; \
    export LC_ALL=C; \
    curl -s -N "http://some.tld/data" \
    | tail -n+2 \
    | awk -F',' '{q=0; o=""; for (i=1; i<=NF; i+=1) {if (q) o=o","$i; else o=o"\t"$i; if ($i == "\"") q=1-q; else{ if (substr($i,length($i),1)=="\"") q=0; else if (substr($i,1,1)=="\"") q=1; }}gsub(/\"/,"",o); print substr(o,2)}' \
    | cut -d $'\t' -f1,3,8 \
    | awk -F '\t' '($3 > 0.97) {print}' \
    | awk -F '\t' '{print $1"\t"$2}'
)

When using a VCS a pretty printed command can be easily compared in comparison to a one line bash command.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions