"newins" and the other "new*" commands should accept "-" as the first argument, denoting standard input. This would allow for "here documents":
newins - foo <<-EOF
# configuration file (for example)
or for using them in a pipe:
sed 's/quux/quuux/' foo | newins - foo
Rationale for extending an existing command instead of introducing a new one is that "-" for standard input is very common with other Unix utilities, and that we should keep the number of commands limited.
To avoid hanging, the commands could test for standard input being a terminal (a simple [ -t 0 ] should be sufficient).
For the record: An alternative proposal is to have a new helper for that. Quoting ciaranm for that:
There's a slightly different variation in exheres-0: as well as do* and
new*, there's also here*, which you use like this:
hereins foo <<'END'
It magically barfs, rather than hanging indefinitely, if you forget to
give it some input.
The rationale for giving it a new name rather than overloading an
existing one is that some of the existing do* utilities don't take just
a single simple filename, so overloading would make the command line
(In reply to comment #1)
> The rationale for giving it a new name rather than overloading an
> existing one is that some of the existing do* utilities don't take just
> a single simple filename, so overloading would make the command line
> somewhat convoluted.
As I already said in -dev, my proposal is only for the new*, but _not_ for the do* commands:
| It doesn't make much sense to specify "-" as an argument for "do*",
| because the command would not know under which name the file should be
| installed. OTOH, all "new*" commands have exactly two arguments, so we
| could allow "-" for the first argument.
Created attachment 321436 [details, diff]
Patch that implements the feature in Portage
Patch for Portage is attached. Please review.
(In reply to comment #3)
> Created attachment 321436 [details, diff] [details, diff]
> Patch that implements the feature in Portage
> Patch for Portage is attached. Please review.
Looks good. I've committed a rebased version of your patch here (much smaller since new* helpers are now symlinks to newins):