Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Simply using cat to dump a single file to STDOUT is technically a misuse because cat is theoretically intended to concatenate files. This 'misuse' is 'solved' by bat because bat seems to be primarily intended for its syntax highlighting and git-related features; according to bat's docs, cat-style concatenation of files is intended for drop-in compatibility with traditional cat.

That said, the idea that using cat to show a single file is "misusing" cat is prescriptivist rules-lawyering. There is no technical reason against using cat for non-concatenation purposes. The descriptivist interpretation of cat says using the tool for non-concatenation purposes is fine, since that's how people are actually using it.

However, note that cat is often misused as a substitute for STDIN redirection:

    # this creates an extra process that wastes
    # time copying STDIN to STDOUT
    cat "${inputfile}" | do_stuff

    # just connect inputfile directly to STDIN
    do_stuff <"${inputfile}"

    # or if you want to keep the input
    # at the start of the pipeline
    <"${inputfile}" do_stuff


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: