Hacker News new | ask | show | jobs
by spiffyk 484 days ago
Thanks for sharing! No immediate use-case for me right now, but good to know something like this exists.

I wanted to point out little nitpicks for the documented shell invocations:

    cat example.md | mdq '# usage'
This can be changed into a stdin file redirect to avoid invoking an extra `cat` process (see Useless use of cat [1]):

    mdq '# usage' < example.md
In a similar fashion, you can avoid an extra `echo` process here:

    echo "$ISSUE_TEXT" | mdq -q '- [x] I have searched for existing issues'
by changing to this:

    mdq -q '- [x] I have searched for existing issues' <<< "$ISSUE_TEXT"
[1]: https://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat
1 comments

From the linked web-page

    A cat written with UUOC might still be preferred for readability reasons, as reading a piped stream left-to-right might be easier to conceptualize.[14] Also, one wrong use of the redirection symbol > instead of < (often adjacent on keyboards) may permanently delete the content of a file, in other words clobbering, and one way to avoid this is to use cat with pipes.
I personally think the cat-style is easier to read since it only uses commands and pipes, with no need to keep track of redirection directions.