No `cat` command
crabdancing opened this issue · 6 comments
Since this project copies a lot from Unixlike OSes, it'd be nice for Unix veterans to include more of the standard Unix functionality. This includes the command cat
, the key behavior of which is:
- If not given a file to
cat
, it simply continuously echos any input from the user.- In *nixes, this is used with piping for simple file editing and file concatenation. Might be nice to implement piping eventually, if people are open to it!
The following uses [foo]
as a placeholder for whatever the user passes to cat
:
- If given a path to an extant file, it will print the contents of this file straight to the terminal then will
exit(0)
. - If given path to an extant directory, it will print:
[foo]/: Is a directory
to STDERR, and then willexit(1)
. - If given nonexistent path, it will say
[foo]/: No such file or directory
to STDERR, and then willexit(1)
.
This behavior is iterative -- it simply iterates over every argument provided, and prints it one after the other, making it useful both for examining files and for rapidly concatenating them together in output.
Sorry, was typing up an explanation!
cat
, and many similar utilities are only really useful if you have pipes. CC doesn't have one, and it's pretty hard to retrofit them in a reliable way, so I'm not sure this really makes much sense - if you want to read a file, you can just use edit
.
As far as redirection goes, IMO it's better provided by an external shell (see lsh and ClamShell for some which do that). It's always somewhat flakey, but that's more permissible in user programs :).
Personally, in my workflows I find the beauty of Unix philosophy is multi-purposeness. In practice I mostly use cat
to quickly probe the contents of files, or to rapidly overwrite/append to them in a simple controlled way.
It's nice not to have to press :q
or Ctrl+X
, or Ctrl
, then select exit
in CC's case, when probing file contents... But you're right that half its uses wouldn't work without piping, sadly. :P
Well, CC's pager is even worse - the quickest way to exit it is to terminate it :p. Really need to fix that at some point.
Worth noting that edit allows you to do Ctrl e to exit, which is slightly faster than Ctrl then exit
. Still stinks, but there we go :D:.