moar icon indicating copy to clipboard operation
moar copied to clipboard

Specify standard input with - (dash)

Open genivia-inc opened this issue 2 years ago • 3 comments

Most *nix utilities support argument - to specify that standard input should be read.

This is useful for several reasons, such as when standard input should be processed together with other files or for automation with a bash script that takes a file argument to invoke moar in the script on that argument, so that - also works for those cases.

genivia-inc avatar Oct 08 '23 20:10 genivia-inc

when standard input should be processed together with other files

moar just accepts one file argument, and I don't see that changing any time soon.

a bash script that takes a file argument to invoke moar in the script on that argument

Sounds like a wrapper script of some kind.

If you have one of these, can you share it?

If moar needs a wrapper script then I'd like to at least consider moving whatever functionality that script provides into moar proper.

walles avatar Oct 11 '23 04:10 walles

@walles even when moar takes one argument only, it is standard in the *nix world to interpret - as standard input. It is useful in scripts too, so one does not need to edit the moar arguments when it takes $FILE when we can set $FILE to -, for example (e.g. testing etc).

genivia-inc avatar Oct 17 '23 16:10 genivia-inc

I've included moar as a recognizable pager in ugrep with argument + to jump to a line number. Since I want to let ugrep display any contents, including the contents of files compressed in zip archives, I need to invoke moar to display standard input. It works fine in my dev version without specifying a file argument to moar, but the logic to do this is more involved with branches than just setting the file argument to - which looks a lot cleaner in the source code.

genivia-inc avatar Oct 17 '23 23:10 genivia-inc