ccat
ccat copied to clipboard
Allow -t switch
Hi,
I recently got the following error from a script that I run regularly
Error: unknown shorthand flag: 't' in -t
Run 'ccat help' for usage.
From man cat
-t Display non-printing characters (see the -v option), and display tab characters as `^I'.
Could ccat at least ignore that switch to be compatible with the cat
command on macOS?
Kind regards, David
Other default switches of cat would be
-b Number the non-blank output lines, starting at 1.
-e Display non-printing characters (see the -v option), and display a dollar sign (`$') at the end of each line.
-n Number the output lines, starting at 1.
-s Squeeze multiple adjacent empty lines, causing the output to be single spaced.
-t Display non-printing characters (see the -v option), and display tab characters as `^I'.
-u Disable output buffering.
-v Display non-printing characters so they are visible. Control characters print as `^X' for control-X; the delete character (octal 0177) prints as `^?'. Non-ASCII characters (with the high bit
set) are printed as `M-' (for meta) followed by the character for the low 7 bits.
@dctr you can still do:
cat -n -t package.json | ccat
Sure, but I have aliased ccat to cat for convenience. So if I want to use it on the console I have to type 'cat'
, which is still ok, but if cat is being used in a script, which is what made me open this issue, I have to unalias it before first and realias is afterwards.
I thing being able to use ccat as a drop-in replacement for cat (e.g. by directly aliasing it) is a valid use case. But to faciliate that, ccat should to it's best to comply to cat's API. Adding additional flags is surely no problem, but being backwards compatible to pre-existing flags -- at least in my opinion -- is important.
This is doable. Instead of reimplementing all flags for cat
, we could shell out to cat
from ccat
with the syntax highlighting content.