On 12/26/23 04:53, Kaz Kylheku wrote:
The feature is actually implementable. The cat program has a way of determining that it has been passed all the names that may arise from the expansion of *. (Modulo a minor sampling-related race condition.) Namely, it can just call glob("*", ...) and compare the results to its argument vector.
Besides the race, there's inherently no way to tell if the user specified the files explicitly or whether the shell has expanded them by globbing. E.g. the following trivial example would fail (I have defined your function of the later post as 'mycat'): # Prep a new dir with just one file. $ mkdir tmp $ cd tmp $ touch file # Try regular 'cat' versus the glob-checking 'mycat'. $ cat file $ mycat file cat: match for * present in command line! I'd rather personally avoid such a function. It's anyway better to teach people - or to learn, depends on hoe one sees it - to avoid using cat(1) on unknown files on the terminal, because binary output may interfere with terminal business. Have a nice day, Berny