ccat icon indicating copy to clipboard operation
ccat copied to clipboard

Allow -t switch

Open dctr opened this issue 7 years ago • 4 comments

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

dctr avatar Oct 10 '16 20:10 dctr

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 avatar Feb 01 '17 00:02 dctr

@dctr you can still do:

cat -n -t package.json | ccat

singuerinc avatar Feb 09 '17 12:02 singuerinc

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.

dctr avatar Feb 11 '17 06:02 dctr

This is doable. Instead of reimplementing all flags for cat, we could shell out to cat from ccat with the syntax highlighting content.

owenthereal avatar Feb 16 '17 21:02 owenthereal