compatibility issue with cat while piping in scripts
arnvgh opened this issue · 3 comments
What steps will reproduce the bug?
- get into any folder with some files and execute
ls | cat -n | less
it should give output with numbers (as thecat
man page says-n
for number all output lines)
1 bar
2 foo
(END)
NOTE: even if we don't pipe it with less
it will give the same output. (This is where the incompatibility comes in)
- Doing the same thing with bat
ls | bat -n | less
omits the numbers and prints
bar
foo
(END)
while when I don't pipe the same command in less
it outputs the following
1 bar
2 foo
What did you expect to happen instead?
As bat
meant to be a cat(1) clone
I assume the behavior should be consistent (same in both the cases as cat
).
It should not remove the number lines when it is called with the --number|-n
flag even while piping into other command such as less
.
How did you install bat
?
sudo dnf install bat
bat version and environment
Software version
bat 0.24.0
Operating system
Linux 6.8.4-200.fc39.x86_64
Command-line
bat --diagnostic
Environment variables
SHELL=/usr/bin/zsh
PAGER=less
LESS=-R
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=/home/ag/.config
XDG_CACHE_HOME=/home/ag/.cache
COLORTERM=truecolor
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/ag/.config/bat/config': No such file or directory (os error 2).
Custom assets metadata
Could not read contents of '/home/ag/.cache/bat/metadata.yaml': No such file or directory (os error 2).
Custom assets
'/home/ag/.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 633 (POSIX 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