Skip to content

Wrong order of stdout and stderr in file --help #29

@rusmux

Description

@rusmux

description

file \--help 2>&1 | bat -pl help gives:

  -M LIST                    use LIST as a colon-separated list of magic
                               number files in place of default
  -d                         use default magic file
  -i                         do not further classify regular files
Usage: file [OPTION...] [FILE...]
Determine type of FILEs.

      --help                 display this help and exit
  -v, --version              output version information and exit
  -m, --magic-file LIST      use LIST as a colon-separated list of magic
                               number files
...

Because file writes some part of its help message to stderr and it goes first in the resulting text. Without 2>&1 everything is right:

file \--help | bat -pl help:

Usage: file [OPTION...] [FILE...]
Determine type of FILEs.

      --help                 display this help and exit
  -v, --version              output version information and exit
  -m, --magic-file LIST      use LIST as a colon-separated list of magic
                               number files
...

I think it's quite rare for most tools to write help to stderr, but I guess it's worth mentioning.

$ bat --version

bat 0.25.0

$ COMMAND --help

file \--help 2>&1 | bat -pl help

$ COMMAND --version

file-5.41; magic file from /usr/share/file/magic

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions