Skip to content

bat -n doesn't behave like cat -n #3125

@depesz

Description

@depesz

I'm not entirely sure if it warrants being called a bug, but it's a weird feature that i wasn't expecting.

What steps will reproduce the bug?

  1. Run printf '%s\n' a b c | cat -n | head -n 5
  2. Run printf '%s\n' a b c | bat -n | head -n 5
  3. observe line numbers missing from 2nd command.

What happens?

Line numbers present from running cat:

=$ printf '%s\n' a b c | cat -n | cat -
     1  a
     2  b
     3  c

disappear when running bat:

=$ printf '%s\n' a b c | bat -n | head -n 5
a
b
c

What did you expect to happen instead?

Given that bat is supposedly be replacement of cat, I would expect it to handle cat's options in the same way.

How did you install bat?

cargo install bat


bat version and environment

Software version

bat 0.24.0

Operating system

Linux 6.11.0-9-generic

Command-line

bat --diagnostic

Environment variables

SHELL=/bin/bash
PAGER=less
LESS=-iMFXSx4R
LANG=en_US.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=<not set>
NO_COLOR=<not set>
MANPAGER=<not set>

System Config file

Could not read contents of '/etc/bat/config': No such file or directory (os error 2).

Config file

Could not read contents of '/home/depesz/.config/bat/config': No such file or directory (os error 2).

Custom assets metadata

Could not read contents of '/home/depesz/.cache/bat/metadata.yaml': No such file or directory (os error 2).

Custom assets

'/home/depesz/.cache/bat' not found

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Less version

> less --version
less 643 (GNU regular expressions)
Copyright (C) 1984-2023  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less

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