public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] newins "-" for standard input?
@ 2009-03-23  8:22 Ulrich Mueller
  2009-03-23  8:48 ` Tiziano Müller
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Ulrich Mueller @ 2009-03-23  8:22 UTC (permalink / raw
  To: gentoo-dev

Now that "dosed" is going to be banned, what would people think of
"newins" (and the other "new*" commands) accepting "-" as the first
argument? I don't know how many usage cases there are, but the
following are obvious:

   sed 's/quux/quuux/' foo | newins - foo

It would allow for here documents:

   newins - bar <<-EOF
   # configuration file (for example)
   EOF

or even:

   newins - baz <<<$'# a short\n# file'

Ulrich



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23  8:22 [gentoo-dev] newins "-" for standard input? Ulrich Mueller
@ 2009-03-23  8:48 ` Tiziano Müller
  2009-03-24  6:55   ` Ulrich Mueller
  2009-03-23 11:35 ` Nirbheek Chauhan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Tiziano Müller @ 2009-03-23  8:48 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

Am Montag, den 23.03.2009, 09:22 +0100 schrieb Ulrich Mueller:
> Now that "dosed" is going to be banned, what would people think of
> "newins" (and the other "new*" commands) accepting "-" as the first
> argument? I don't know how many usage cases there are, but the
> following are obvious:
> 
>    sed 's/quux/quuux/' foo | newins - foo
> 
> It would allow for here documents:
> 
>    newins - bar <<-EOF
>    # configuration file (for example)
>    EOF
> 
> or even:
> 
>    newins - baz <<<$'# a short\n# file'
> 

I like it :-)


[-- Attachment #2: Dies ist ein digital signierter Nachrichtenteil --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23  8:22 [gentoo-dev] newins "-" for standard input? Ulrich Mueller
  2009-03-23  8:48 ` Tiziano Müller
@ 2009-03-23 11:35 ` Nirbheek Chauhan
  2009-03-23 14:24 ` Ciaran McCreesh
  2009-03-23 16:11 ` Timothy Redaelli
  3 siblings, 0 replies; 10+ messages in thread
From: Nirbheek Chauhan @ 2009-03-23 11:35 UTC (permalink / raw
  To: gentoo-dev

On Mon, Mar 23, 2009 at 1:52 PM, Ulrich Mueller <ulm@gentoo.org> wrote:
> Now that "dosed" is going to be banned, what would people think of

I wouldn't call it banned, rather "useless" since everyone directly
uses sed instead.


-- 
~Nirbheek Chauhan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23  8:22 [gentoo-dev] newins "-" for standard input? Ulrich Mueller
  2009-03-23  8:48 ` Tiziano Müller
  2009-03-23 11:35 ` Nirbheek Chauhan
@ 2009-03-23 14:24 ` Ciaran McCreesh
  2009-03-23 15:41   ` Ulrich Mueller
  2009-03-23 16:11 ` Timothy Redaelli
  3 siblings, 1 reply; 10+ messages in thread
From: Ciaran McCreesh @ 2009-03-23 14:24 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

On Mon, 23 Mar 2009 09:22:06 +0100
Ulrich Mueller <ulm@gentoo.org> wrote:
> Now that "dosed" is going to be banned, what would people think of
> "newins" (and the other "new*" commands) accepting "-" as the first
> argument?

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.

-- 
Ciaran McCreesh

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23 14:24 ` Ciaran McCreesh
@ 2009-03-23 15:41   ` Ulrich Mueller
  2009-03-23 17:01     ` Alec Warner
  0 siblings, 1 reply; 10+ messages in thread
From: Ulrich Mueller @ 2009-03-23 15:41 UTC (permalink / raw
  To: gentoo-dev

>>>>> On Mon, 23 Mar 2009, Ciaran McCreesh wrote:

>> Now that "dosed" is going to be banned, what would people think of
>> "newins" (and the other "new*" commands) accepting "-" as the first
>> argument?

> 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

Why would we need a new command for this? The minus sign denoting
standard input is fairly common with other utilities.

> It magically barfs, rather than hanging indefinitely, if you forget
> to give it some input.

I guess the same could be done for "newins -", if you think that it is
necessary (test for stdin being a terminal?). But I don't really see
the point of it, since such a mistake would be noticed immediately
when testing the ebuild.

> 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.

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.

Ulrich



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23  8:22 [gentoo-dev] newins "-" for standard input? Ulrich Mueller
                   ` (2 preceding siblings ...)
  2009-03-23 14:24 ` Ciaran McCreesh
@ 2009-03-23 16:11 ` Timothy Redaelli
  2009-03-23 16:24   ` Michael Haubenwallner
  3 siblings, 1 reply; 10+ messages in thread
From: Timothy Redaelli @ 2009-03-23 16:11 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 820 bytes --]

On Monday 23 March 2009 09:22:06 Ulrich Mueller wrote:
> Now that "dosed" is going to be banned, what would people think of
> "newins" (and the other "new*" commands) accepting "-" as the first
> argument? I don't know how many usage cases there are, but the
> following are obvious:
>
>    sed 's/quux/quuux/' foo | newins - foo
>
> It would allow for here documents:
>
>    newins - bar <<-EOF
>    # configuration file (for example)
>    EOF
>
> or even:
>
>    newins - baz <<<$'# a short\n# file'

Why can't you use "newins /dev/stdin foo" that it works out of the box?

-- 
Timothy `Drizzt` Redaelli
FreeSBIE Developer, Gentoo Developer, GUFI Staff
There are two major products that come out of Berkeley: LSD and UNIX.
We don't believe this to be a coincidence.      -- Jeremy S. Anderson

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23 16:11 ` Timothy Redaelli
@ 2009-03-23 16:24   ` Michael Haubenwallner
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Haubenwallner @ 2009-03-23 16:24 UTC (permalink / raw
  To: gentoo-dev

On Mon, 2009-03-23 at 17:11 +0100, Timothy Redaelli wrote:
> On Monday 23 March 2009 09:22:06 Ulrich Mueller wrote:

> >
> >    newins - baz <<<$'# a short\n# file'
> 
> Why can't you use "newins /dev/stdin foo" that it works out of the box?

Nope, /dev/stdin isn't portable.

While Linux and Solaris have it, AIX and HP-UX do not
provide /dev/stdin. Unsure about Interix and MacOSX.

Using '-' sounds familiar for me too.

/haubi/




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23 15:41   ` Ulrich Mueller
@ 2009-03-23 17:01     ` Alec Warner
  2009-03-26  1:07       ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Alec Warner @ 2009-03-23 17:01 UTC (permalink / raw
  To: gentoo-dev

On Mon, Mar 23, 2009 at 8:41 AM, Ulrich Mueller <ulm@gentoo.org> wrote:
>>>>>> On Mon, 23 Mar 2009, Ciaran McCreesh wrote:
>
>>> Now that "dosed" is going to be banned, what would people think of
>>> "newins" (and the other "new*" commands) accepting "-" as the first
>>> argument?
>
>> 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
>
> Why would we need a new command for this? The minus sign denoting
> standard input is fairly common with other utilities.
>
>> It magically barfs, rather than hanging indefinitely, if you forget
>> to give it some input.
>
> I guess the same could be done for "newins -", if you think that it is
> necessary (test for stdin being a terminal?). But I don't really see
> the point of it, since such a mistake would be noticed immediately
> when testing the ebuild.

No, they aren't 'noticed immediately'.  The ebuild hangs and then the
author spends 10 minutes trying to figure out why.  If its trivial to
implement..I don't see a downside to such a feature.

>
>> 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.
>
> 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.
>
> Ulrich
>
>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23  8:48 ` Tiziano Müller
@ 2009-03-24  6:55   ` Ulrich Mueller
  0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Mueller @ 2009-03-24  6:55 UTC (permalink / raw
  To: gentoo-dev

>>>>> On Mon, 23 Mar 2009, Tiziano Müller wrote:

>> what would people think of "newins" (and the other "new*" commands)
>> accepting "-" as the first argument?

> I like it :-)

Bug 263565 now.

Ulrich



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] newins "-" for standard input?
  2009-03-23 17:01     ` Alec Warner
@ 2009-03-26  1:07       ` Mike Frysinger
  0 siblings, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2009-03-26  1:07 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1677 bytes --]

On Monday 23 March 2009 13:01:46 Alec Warner wrote:
> On Mon, Mar 23, 2009 at 8:41 AM, Ulrich Mueller <ulm@gentoo.org> wrote:
> >>>>>> On Mon, 23 Mar 2009, Ciaran McCreesh wrote:
> >>>
> >>> Now that "dosed" is going to be banned, what would people think of
> >>> "newins" (and the other "new*" commands) accepting "-" as the first
> >>> argument?
> >>
> >> 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
> >
> > Why would we need a new command for this? The minus sign denoting
> > standard input is fairly common with other utilities.
> >
> >> It magically barfs, rather than hanging indefinitely, if you forget
> >> to give it some input.
> >
> > I guess the same could be done for "newins -", if you think that it is
> > necessary (test for stdin being a terminal?). But I don't really see
> > the point of it, since such a mistake would be noticed immediately
> > when testing the ebuild.
>
> No, they aren't 'noticed immediately'.  The ebuild hangs and then the
> author spends 10 minutes trying to figure out why.  If its trivial to
> implement..I don't see a downside to such a feature.

this "feature" can be found in any number of existing utilities.  like sed.  
any argument along those lines is pretty weak.  using "-" as a shortcut name 
for stdin sounds logical to me considering it's a standard in the *nix world.

as for the portage utils checking stdin and reporting an error if it's trying 
to grab from the terminal, that's cheese someone can implement if they really 
want it.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-03-26  1:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23  8:22 [gentoo-dev] newins "-" for standard input? Ulrich Mueller
2009-03-23  8:48 ` Tiziano Müller
2009-03-24  6:55   ` Ulrich Mueller
2009-03-23 11:35 ` Nirbheek Chauhan
2009-03-23 14:24 ` Ciaran McCreesh
2009-03-23 15:41   ` Ulrich Mueller
2009-03-23 17:01     ` Alec Warner
2009-03-26  1:07       ` Mike Frysinger
2009-03-23 16:11 ` Timothy Redaelli
2009-03-23 16:24   ` Michael Haubenwallner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox