0

If I list the ID3 tags of an MP3 file with eyeD3, the full file name/path is shown in green, and the file size spaced over to the right edge of the Terminal window.  Before and after, a line of hyphens also goes the full width. But if I pipe the output through od -xc, the line of hyphens is much shorter, the escape sequences are not shown, three periods replace a large part of the path/name, and there is no space between filename and size.  Example below.

Is it a bug? If yes, which tool is the bug in? (I suspect it is not possible for eyeD3 to detect the pipe and change behavior.)

0000540      676e    0a5d    614c    676e    6175    6567    2d0a    2d2d
           n   g   ]  \n   L   a   n   g   u   a   g   e  \n   -   -   -
0000560      2d2d    2d2d    2d2d    2d2d    2d2d    2d2d    2d2d    2d2d
           -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
0000600      2d2d    2d2d    2d2d    2e0a    2e2e    6f72    206c    7542
           -   -   -   -   -   -  \n   .   .   .   r   o   l       B   u

1 Answer 1

3

No, it is not a bug - it is intended behavior.

You suspicion is incorrect - it is actually possible for eyeD3 to detect the pipe - and that's what it does.

If you look at the source code for eyeD3 in file eyeD3/console.py approx line 75 - you'll see the following:

def _term_supports_color():
        if (os.environ.get("TERM") == "dumb" or
                os.environ.get("OS") == "Windows_NT"):
            return False
        return hasattr(sys.stdout, "isatty") and sys.stdout.isatty()

What happens here is that eyeD3 checks whether the standard output is a tty or not - and that is used to decide whether to use escape codes for (amongst other things) coloring the output. When you run the command normally, you do have a tty. When you run the command and pipe it into od, you no longer have a tty.

2
  • IS it a bug for it to omit most of the file path in that case? I guess not, since it apparently intentionally puts in three periods (ellipsis).
    – WGroleau
    Commented Jan 27, 2022 at 3:56
  • No, it’s not a bug. When you have a tty it can ask the Terminal for the width of your Terminal and output longer output if applicable - without that information it has to default to some, less wide setting. That’s why many programs has a setting to output full data without cropping.
    – jksoegaard
    Commented Jan 27, 2022 at 6:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .