Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 263565 - [Future EAPI] newins et al. should accept "-" for standard input
Summary: [Future EAPI] newins et al. should accept "-" for standard input
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: PMS/EAPI
URL:
Whiteboard: in-eapi-5
Keywords:
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2009-03-24 06:53 UTC by Ulrich Müller
Modified: 2012-09-23 06:40 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch that implements the feature in Portage (0001-EAPI-5-new-commands-can-read-from-stdin-bug-263565.patch,11.68 KB, patch)
2012-08-15 20:56 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2009-03-24 06:53:22 UTC
"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)
   EOF

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).
Comment 1 Tiziano Müller (RETIRED) gentoo-dev 2009-03-25 09:25:13 UTC
For the record: An alternative proposal is to have a new helper for that. Quoting ciaranm for that:
*snip*
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'
stuff
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
somewhat convoluted.
*snip*
Comment 2 Ulrich Müller gentoo-dev 2009-03-25 09:41:21 UTC
(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.
Comment 3 Ulrich Müller gentoo-dev 2012-08-15 20:56:57 UTC
Created attachment 321436 [details, diff]
Patch that implements the feature in Portage

Patch for Portage is attached. Please review.
Comment 4 Zac Medico gentoo-dev 2012-08-25 20:03:43 UTC
(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):

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ffe2a5b5f70be05565b5a3038637805319088743