Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Your files are now being encrypted and thrown into the bit bucket. EOF


devel / comp.lang.c / Piping to stdin

SubjectAuthor
* Piping to stdinMalcolm McLean
+* Re: Piping to stdinSpiros Bousbouras
|`* Re: Piping to stdinMalcolm McLean
| +* Re: Piping to stdinBart
| |+* Re: Piping to stdinMalcolm McLean
| ||`- Re: Piping to stdinBart
| |`- Re: Piping to stdinScott Lurndal
| +- Re: Piping to stdinScott Lurndal
| +* Re: Piping to stdinLew Pitcher
| |`* Re: Piping to stdinKaz Kylheku
| | `- Re: Piping to stdinScott Lurndal
| +* Re: Piping to stdinBen Bacarisse
| |`- Re: Piping to stdinScott Lurndal
| `* Re: Piping to stdinKenny McCormack
|  +* Re: Piping to stdinKaz Kylheku
|  |`* Re: Piping to stdinKenny McCormack
|  | `* Re: Piping to stdinKalevi Kolttonen
|  |  `* Re: Piping to stdinGary R. Schmidt
|  |   +* Re: Piping to stdinKaz Kylheku
|  |   |+- Re: Piping to stdinKeith Thompson
|  |   |+* Re: Piping to stdinRichard Kettlewell
|  |   ||+- Dealing with weird filenames (Was: Piping to stdin)Kenny McCormack
|  |   ||+* Re: Piping to stdinDavid Brown
|  |   |||+* Re: Piping to stdinRichard Harnden
|  |   ||||+- Re: Piping to stdinScott Lurndal
|  |   ||||`- Re: Piping to stdinvallor
|  |   |||`* Re: Piping to stdinRichard Kettlewell
|  |   ||| `* Re: Piping to stdinScott Lurndal
|  |   |||  +- Re: Piping to stdinKenny McCormack
|  |   |||  +- Re: Piping to stdinKeith Thompson
|  |   |||  `- Re: Piping to stdinPhil Carmody
|  |   ||`* Re: Piping to stdinJames Kuyper
|  |   || `- Re: Piping to stdinDavid Brown
|  |   |`* Re: Piping to stdinJoe Pfeiffer
|  |   | `* Re: Piping to stdinRichard Harnden
|  |   |  `- Re: Piping to stdinPhil Carmody
|  |   `* Re: Piping to stdinKalevi Kolttonen
|  |    +* Re: Piping to stdinGiovanni
|  |    |`* Re: Piping to stdinKenny McCormack
|  |    | `* Re: Piping to stdinKalevi Kolttonen
|  |    |  +* Re: Piping to stdinMuttley
|  |    |  |+* Re: Piping to stdinKalevi Kolttonen
|  |    |  ||`* Re: Piping to stdinMuttley
|  |    |  || `* Re: Piping to stdinKalevi Kolttonen
|  |    |  ||  `- Re: Piping to stdinScott Lurndal
|  |    |  |+- Re: Piping to stdinKaz Kylheku
|  |    |  |`* Re: Piping to stdinPhil Carmody
|  |    |  | `* Re: Piping to stdinMuttley
|  |    |  |  +* Re: Piping to stdinPhil Carmody
|  |    |  |  |+* Re: Piping to stdinMichael S
|  |    |  |  ||`* Re: Piping to stdinAnton Shepelev
|  |    |  |  || +- Re: Piping to stdincandycanearter07
|  |    |  |  || `- Re: Piping to stdincandycanearter07
|  |    |  |  |+* Wrecking a good thing? (Was: Piping to stdin)Kenny McCormack
|  |    |  |  ||+- Re: Wrecking a good thing?Phil Carmody
|  |    |  |  ||`- Re: Wrecking a good thing? (Was: Piping to stdin)David Brown
|  |    |  |  |+- Re: Piping to stdinMuttley
|  |    |  |  |`- Re: Piping to stdinÖö Tiib
|  |    |  |  +* Re: Piping to stdinKaz Kylheku
|  |    |  |  |+- Re: Piping to stdinMuttley
|  |    |  |  |+- Re: Piping to stdinKeith Thompson
|  |    |  |  |`- Re: Piping to stdinDavid Brown
|  |    |  |  `* Re: Piping to stdinBen Bacarisse
|  |    |  |   `* Re: Piping to stdinPhil Carmody
|  |    |  |    +* Re: Piping to stdinOğuz
|  |    |  |    |`* Re: Piping to stdinMuttley
|  |    |  |    | +* Re: Piping to stdinScott Lurndal
|  |    |  |    | |`- Re: Piping to stdinMuttley
|  |    |  |    | `* Re: Piping to stdinRainer Weikusat
|  |    |  |    |  `* What language is this? (Was: Piping to stdin)Kenny McCormack
|  |    |  |    |   `* Re: What language is this? (Was: Piping to stdin)Scott Lurndal
|  |    |  |    |    +* Re: What language is this? (Was: Piping to stdin)Kenny McCormack
|  |    |  |    |    |`* Re: What language is this?Rainer Weikusat
|  |    |  |    |    | `* Re: What language is this?Kenny McCormack
|  |    |  |    |    |  `* Re: What language is this?Rainer Weikusat
|  |    |  |    |    |   `* Re: What language is this?Kenny McCormack
|  |    |  |    |    |    `- Re: What language is this?Rainer Weikusat
|  |    |  |    |    `- Re: What language is this? (Was: Piping to stdin)Muttley
|  |    |  |    `- Re: Piping to stdinBen Bacarisse
|  |    |  +* Re: Piping to stdinPhil Carmody
|  |    |  |`* Re: Piping to stdinLew Pitcher
|  |    |  | `* Re: Piping to stdinPhil Carmody
|  |    |  |  `* Re: Piping to stdinLew Pitcher
|  |    |  |   +- Re: Piping to stdinKaz Kylheku
|  |    |  |   `- Re: Piping to stdinPhil Carmody
|  |    |  `- Re: Piping to stdinBen Bacarisse
|  |    `- Re: Piping to stdinPhil Carmody
|  `- Re: Piping to stdinNuno Silva
+* Re: Piping to stdinScott Lurndal
|`* Re: Piping to stdinKeith Thompson
| `* Re: Piping to stdinKenny McCormack
|  +* Re: Piping to stdinKaz Kylheku
|  |+- Re: Piping to stdinPhil Carmody
|  |`* Re: Piping to stdinKeith Thompson
|  | +* Re: Piping to stdinMalcolm McLean
|  | |`- Re: Piping to stdinKenny McCormack
|  | `* Re: Piping to stdinKaz Kylheku
|  |  `- Re: Piping to stdinBen Bacarisse
|  `* Re: Piping to stdinJim Jackson
|   `- Re: Piping to stdinMichael S
+- Re: Piping to stdinJohn Forkosh
`* Re: Piping to stdinKenny McCormack

Pages:12345
Piping to stdin

<9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27545&group=comp.lang.c#27545

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9305:0:b0:765:942d:b19 with SMTP id v5-20020a379305000000b00765942d0b19mr85447qkd.13.1691934138876;
Sun, 13 Aug 2023 06:42:18 -0700 (PDT)
X-Received: by 2002:a63:3343:0:b0:564:8378:3afb with SMTP id
z64-20020a633343000000b0056483783afbmr1304789pgz.3.1691934138403; Sun, 13 Aug
2023 06:42:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:a13e:e92d:ba00:c2b1;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:a13e:e92d:ba00:c2b1
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
Subject: Piping to stdin
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 13 Aug 2023 13:42:18 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1507
 by: Malcolm McLean - Sun, 13 Aug 2023 13:42 UTC

On Unix-lke systems, what is the convention for putting a program into a
mode where it accepts input from stdin?
Where the user invokes it directly, he'll normally want input from a file. So
the normal invocation would be

myprogram myinput.txt

But if he just types "myprogram" it should display brief help text. So we
can't omit the filename to make the program read from stdin.

So do you pass an option

myprogram -stdin

or what is the normal way of solving this?

Re: Piping to stdin

<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27547&group=comp.lang.c#27547

  copy link   Newsgroups: comp.lang.c comp.unix.programmer
Followup: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c,comp.unix.programmer
Subject: Re: Piping to stdin
Followup-To: comp.unix.programmer
Date: Sun, 13 Aug 2023 13:55:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 13 Aug 2023 13:55:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3be25fa73c86264f344f4f91b574e804";
logging-data="1959227"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RFtiBSZ8vO18mGF4iBnnu"
Cancel-Lock: sha1:YrWYlxKthIK3KVf9wwUh3/vEE3I=
In-Reply-To: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Sun, 13 Aug 2023 13:55 UTC

[ Followup-To: comp.unix.programmer ]

On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> On Unix-lke systems, what is the convention for putting a program into a
> mode where it accepts input from stdin?
> Where the user invokes it directly, he'll normally want input from a file. So
> the normal invocation would be
>
> myprogram myinput.txt
>
> But if he just types "myprogram" it should display brief help text. So we
> can't omit the filename to make the program read from stdin.

I would use a -h option for help text and with no arguments it should read
from stdin .

> So do you pass an option
>
> myprogram -stdin
>
> or what is the normal way of solving this?

- (a single dash) as argument. Even if the programme accepts multiple file
name arguments , a single dash among those means "read from stdin".

--
vlaho.ninja/prog

Re: Piping to stdin

<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27548&group=comp.lang.c#27548

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:7d92:0:b0:403:c200:cd07 with SMTP id c18-20020ac87d92000000b00403c200cd07mr88070qtd.4.1691935676054;
Sun, 13 Aug 2023 07:07:56 -0700 (PDT)
X-Received: by 2002:a63:3e87:0:b0:564:3087:dd22 with SMTP id
l129-20020a633e87000000b005643087dd22mr1242592pga.9.1691935675584; Sun, 13
Aug 2023 07:07:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 13 Aug 2023 07:07:55 -0700 (PDT)
In-Reply-To: <U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:a13e:e92d:ba00:c2b1;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:a13e:e92d:ba00:c2b1
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
Subject: Re: Piping to stdin
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 13 Aug 2023 14:07:56 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2430
 by: Malcolm McLean - Sun, 13 Aug 2023 14:07 UTC

On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
> [ Followup-To: comp.unix.programmer ]
> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
> > On Unix-lke systems, what is the convention for putting a program into a
> > mode where it accepts input from stdin?
> > Where the user invokes it directly, he'll normally want input from a file. So
> > the normal invocation would be
> >
> > myprogram myinput.txt
> >
> > But if he just types "myprogram" it should display brief help text. So we
> > can't omit the filename to make the program read from stdin.
> I would use a -h option for help text and with no arguments it should read
> from stdin .
>
That's unacceptable to me. My users will expect that when they see a program
and type the name, it will either launch a GUI or print out. a brief message
saying what the program is and what it does.
>
> > So do you pass an option
> >
> > myprogram -stdin
> >
> > or what is the normal way of solving this?
> - (a single dash) as argument. Even if the programme accepts multiple file
> name arguments , a single dash among those means "read from stdin".
>
So conventionally the file name is "-"?

Re: Piping to stdin

<ubaott$1ru3v$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27549&group=comp.lang.c#27549

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Sun, 13 Aug 2023 15:21:50 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <ubaott$1ru3v$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 13 Aug 2023 14:21:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="504c96876f9fd3dcf0f1cd3ca02e563f";
logging-data="1964159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IueYR+8kVVW6afmK/tSko1+1XNF9Mq2Y="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:fJUFY8n+M0i8j+ROY1cE9/9dzc0=
In-Reply-To: <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
 by: Bart - Sun, 13 Aug 2023 14:21 UTC

On 13/08/2023 15:07, Malcolm McLean wrote:
> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>> [ Followup-To: comp.unix.programmer ]
>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>>> On Unix-lke systems, what is the convention for putting a program into a
>>> mode where it accepts input from stdin?
>>> Where the user invokes it directly, he'll normally want input from a file. So
>>> the normal invocation would be
>>>
>>> myprogram myinput.txt
>>>
>>> But if he just types "myprogram" it should display brief help text. So we
>>> can't omit the filename to make the program read from stdin.
>> I would use a -h option for help text and with no arguments it should read
>> from stdin .
>>
> That's unacceptable to me. My users will expect that when they see a program
> and type the name, it will either launch a GUI or print out. a brief message
> saying what the program is and what it does.
>>
>>> So do you pass an option
>>>
>>> myprogram -stdin
>>>
>>> or what is the normal way of solving this?
>> - (a single dash) as argument. Even if the programme accepts multiple file
>> name arguments , a single dash among those means "read from stdin".
>>
> So conventionally the file name is "-"?

Yeah, obviously!

But on a program like gcc, you will also need -xc to tell it it's a C
file for example.

My own product is unconventional and uses -stdin. No filename is needed
then. Input is from the keyboard unless < has been used to redirect
input from a file, or file-like source.

I've never actually used it, and no other programs of mine have that.

But lots of programs will either take a file name, or enter interactive
mode such as the REPL of an interpreter if the file name is missing.

What is the behaviour you're after?

Re: Piping to stdin

<17bed113-a835-4364-9e5f-10b7b5f67afen@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27550&group=comp.lang.c#27550

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:7dcb:0:b0:40f:dc70:fddb with SMTP id c11-20020ac87dcb000000b0040fdc70fddbmr77705qte.10.1691937117323;
Sun, 13 Aug 2023 07:31:57 -0700 (PDT)
X-Received: by 2002:a63:6d8f:0:b0:542:c9ed:b with SMTP id i137-20020a636d8f000000b00542c9ed000bmr1370149pgc.7.1691937116893;
Sun, 13 Aug 2023 07:31:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 13 Aug 2023 07:31:56 -0700 (PDT)
In-Reply-To: <ubaott$1ru3v$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:a13e:e92d:ba00:c2b1;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:a13e:e92d:ba00:c2b1
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co> <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
<ubaott$1ru3v$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <17bed113-a835-4364-9e5f-10b7b5f67afen@googlegroups.com>
Subject: Re: Piping to stdin
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 13 Aug 2023 14:31:57 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3738
 by: Malcolm McLean - Sun, 13 Aug 2023 14:31 UTC

On Sunday, 13 August 2023 at 15:22:03 UTC+1, Bart wrote:
> On 13/08/2023 15:07, Malcolm McLean wrote:
> > On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
> >> [ Followup-To: comp.unix.programmer ]
> >> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
> >> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
> >>> On Unix-lke systems, what is the convention for putting a program into a
> >>> mode where it accepts input from stdin?
> >>> Where the user invokes it directly, he'll normally want input from a file. So
> >>> the normal invocation would be
> >>>
> >>> myprogram myinput.txt
> >>>
> >>> But if he just types "myprogram" it should display brief help text. So we
> >>> can't omit the filename to make the program read from stdin.
> >> I would use a -h option for help text and with no arguments it should read
> >> from stdin .
> >>
> > That's unacceptable to me. My users will expect that when they see a program
> > and type the name, it will either launch a GUI or print out. a brief message
> > saying what the program is and what it does.
> >>
> >>> So do you pass an option
> >>>
> >>> myprogram -stdin
> >>>
> >>> or what is the normal way of solving this?
> >> - (a single dash) as argument. Even if the programme accepts multiple file
> >> name arguments , a single dash among those means "read from stdin".
> >>
> > So conventionally the file name is "-"?
> Yeah, obviously!
>
> But on a program like gcc, you will also need -xc to tell it it's a C
> file for example.
>
> My own product is unconventional and uses -stdin. No filename is needed
> then. Input is from the keyboard unless < has been used to redirect
> input from a file, or file-like source.
>
> I've never actually used it, and no other programs of mine have that.
>
> But lots of programs will either take a file name, or enter interactive
> mode such as the REPL of an interpreter if the file name is missing.
>
> What is the behaviour you're after?
>
I don't actually know.
The program is an XML to CSV file converter. My main motive for writing it
was to test the new vanilla XML parser. But some people like to set up
pipelines whereby the output of one program is chained to the input of another.
It's not. a style of working that I have ever used, however I understand that
in some environments, it's very important to have this ability.

I want it to support their needs.

Re: Piping to stdin

<ubatgn$1siaf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27552&group=comp.lang.c#27552

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Sun, 13 Aug 2023 16:40:07 +0100
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <ubatgn$1siaf$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
<ubaott$1ru3v$1@dont-email.me>
<17bed113-a835-4364-9e5f-10b7b5f67afen@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 13 Aug 2023 15:40:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="504c96876f9fd3dcf0f1cd3ca02e563f";
logging-data="1984847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HtfH9btMBU3j+agiZIM8pwOwoyowFeDM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:kuV0OEXjhSs0mRPJHU6VV5b8T94=
In-Reply-To: <17bed113-a835-4364-9e5f-10b7b5f67afen@googlegroups.com>
 by: Bart - Sun, 13 Aug 2023 15:40 UTC

On 13/08/2023 15:31, Malcolm McLean wrote:
> On Sunday, 13 August 2023 at 15:22:03 UTC+1, Bart wrote:
>> On 13/08/2023 15:07, Malcolm McLean wrote:
>>> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>>>> [ Followup-To: comp.unix.programmer ]
>>>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>>>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>>>>> On Unix-lke systems, what is the convention for putting a program into a
>>>>> mode where it accepts input from stdin?
>>>>> Where the user invokes it directly, he'll normally want input from a file. So
>>>>> the normal invocation would be
>>>>>
>>>>> myprogram myinput.txt
>>>>>
>>>>> But if he just types "myprogram" it should display brief help text. So we
>>>>> can't omit the filename to make the program read from stdin.
>>>> I would use a -h option for help text and with no arguments it should read
>>>> from stdin .
>>>>
>>> That's unacceptable to me. My users will expect that when they see a program
>>> and type the name, it will either launch a GUI or print out. a brief message
>>> saying what the program is and what it does.
>>>>
>>>>> So do you pass an option
>>>>>
>>>>> myprogram -stdin
>>>>>
>>>>> or what is the normal way of solving this?
>>>> - (a single dash) as argument. Even if the programme accepts multiple file
>>>> name arguments , a single dash among those means "read from stdin".
>>>>
>>> So conventionally the file name is "-"?
>> Yeah, obviously!
>>
>> But on a program like gcc, you will also need -xc to tell it it's a C
>> file for example.
>>
>> My own product is unconventional and uses -stdin. No filename is needed
>> then. Input is from the keyboard unless < has been used to redirect
>> input from a file, or file-like source.
>>
>> I've never actually used it, and no other programs of mine have that.
>>
>> But lots of programs will either take a file name, or enter interactive
>> mode such as the REPL of an interpreter if the file name is missing.
>>
>> What is the behaviour you're after?
>>
> I don't actually know.
> The program is an XML to CSV file converter. My main motive for writing it
> was to test the new vanilla XML parser. But some people like to set up
> pipelines whereby the output of one program is chained to the input of another.
> It's not. a style of working that I have ever used, however I understand that
> in some environments, it's very important to have this ability.
>
> I want it to support their needs.

I think I would just have a differently named executable that did that:
take input from stdint and write output to stdout.

So no messing with options. It could even be the identical file (a copy
of the same EXE, or a link), but some code inside can look at name used
to invoke it.

Re: Piping to stdin

<mc7CM.741128$GMN3.387092@fx16.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27558&group=comp.lang.c#27558

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Piping to stdin
Newsgroups: comp.lang.c
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
Lines: 36
Message-ID: <mc7CM.741128$GMN3.387092@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 13 Aug 2023 16:06:42 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 13 Aug 2023 16:06:42 GMT
X-Received-Bytes: 1671
 by: Scott Lurndal - Sun, 13 Aug 2023 16:06 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>On Unix-lke systems, what is the convention for putting a program into a
>mode where it accepts input from stdin?

Every program accepts input from stdin.

>Where the user invokes it directly, he'll normally want input from a file. So
>the normal invocation would be
>
>myprogram myinput.txt

Or, it might be:

$ cat myinput.txt | myprogram (where the lack of argument presumes stdin)

or

$ cat myinput.txt | myprogram -

(where the single hyphen indicates that input is from stdin, vs. a filename
specified on the command line).

or

$ myprogram < myinput.txt

>
>But if he just types "myprogram" it should display brief help text. So we
>can't omit the filename to make the program read from stdin.

Most programs in unix will accept '-?' or '-h' or some other flag
to indicate that usage information is to be printed. Many utilities
will print usage information if the input arguments are not valid.

Re: Piping to stdin

<Vc7CM.741129$GMN3.377717@fx16.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27559&group=comp.lang.c#27559

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Piping to stdin
Newsgroups: comp.lang.c
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <U4x2oQwlZ0Kk8WwnO@bongo-ra.co> <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
Lines: 20
Message-ID: <Vc7CM.741129$GMN3.377717@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 13 Aug 2023 16:07:17 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 13 Aug 2023 16:07:17 GMT
X-Received-Bytes: 1521
 by: Scott Lurndal - Sun, 13 Aug 2023 16:07 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>> [ Followup-To: comp.unix.programmer ]
>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>> > On Unix-lke systems, what is the convention for putting a program into a
>> > mode where it accepts input from stdin?
>> > Where the user invokes it directly, he'll normally want input from a file. So
>> > the normal invocation would be
>> >
>> > myprogram myinput.txt
>> >
>> > But if he just types "myprogram" it should display brief help text. So we
>> > can't omit the filename to make the program read from stdin.
>> I would use a -h option for help text and with no arguments it should read
>> from stdin .
>>
>That's unacceptable to me.

That's life.

Re: Piping to stdin

<%d7CM.741130$GMN3.298008@fx16.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27560&group=comp.lang.c#27560

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Piping to stdin
Newsgroups: comp.lang.c
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <U4x2oQwlZ0Kk8WwnO@bongo-ra.co> <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com> <ubaott$1ru3v$1@dont-email.me>
Lines: 38
Message-ID: <%d7CM.741130$GMN3.298008@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 13 Aug 2023 16:08:27 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 13 Aug 2023 16:08:27 GMT
X-Received-Bytes: 2268
 by: Scott Lurndal - Sun, 13 Aug 2023 16:08 UTC

Bart <bc@freeuk.com> writes:
>On 13/08/2023 15:07, Malcolm McLean wrote:
>> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>>> [ Followup-To: comp.unix.programmer ]
>>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>>>> On Unix-lke systems, what is the convention for putting a program into a
>>>> mode where it accepts input from stdin?
>>>> Where the user invokes it directly, he'll normally want input from a file. So
>>>> the normal invocation would be
>>>>
>>>> myprogram myinput.txt
>>>>
>>>> But if he just types "myprogram" it should display brief help text. So we
>>>> can't omit the filename to make the program read from stdin.
>>> I would use a -h option for help text and with no arguments it should read
>>> from stdin .
>>>
>> That's unacceptable to me. My users will expect that when they see a program
>> and type the name, it will either launch a GUI or print out. a brief message
>> saying what the program is and what it does.
>>>
>>>> So do you pass an option
>>>>
>>>> myprogram -stdin
>>>>
>>>> or what is the normal way of solving this?
>>> - (a single dash) as argument. Even if the programme accepts multiple file
>>> name arguments , a single dash among those means "read from stdin".
>>>
>> So conventionally the file name is "-"?
>
>Yeah, obviously!

Yes, obviously. He asked about unix. It has been quite clear
for several decades what the requirements are.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

Re: Piping to stdin

<ubb3nd$1sk6k$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27564&group=comp.lang.c#27564

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Sun, 13 Aug 2023 17:26:05 -0000 (UTC)
Organization: The Pitcher Digital Freehold
Lines: 63
Message-ID: <ubb3nd$1sk6k$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 13 Aug 2023 17:26:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a814fd65136a1c40d7dfacf7af1af11f";
logging-data="1986772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ne4e2eK1Kk/AbAlGgjDy7oUYPKMjyrHA="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:kFDTiVX8hm3WmYyyktrJNfIMqm8=
 by: Lew Pitcher - Sun, 13 Aug 2023 17:26 UTC

On Sun, 13 Aug 2023 07:07:55 -0700, Malcolm McLean wrote:

> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>> [ Followup-To: comp.unix.programmer ]
>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>> > On Unix-lke systems, what is the convention for putting a program into a
>> > mode where it accepts input from stdin?

The Unix convention is that a program /defaults/ to accepting data on stdin.
If the program can accept alternate input sources, then either
a) specific commandline arguments are used to change the input source, or
b) the input source is the last argument in the commandline argument list
(POSIX/SUS suggests that, if the last argument is '-', then the program
will revert back to accepting input from stdin)

>> > Where the user invokes it directly, he'll normally want input from a file. So
>> > the normal invocation would be
>> >
>> > myprogram myinput.txt
>> >
>> > But if he just types "myprogram" it should display brief help text.

Yah, no. That behaviour is contrary to Unix convention. To get the help
summary, the Unix convention is to add a specific argument flag (typically -h),
to the commandline

>> > So we
>> > can't omit the filename to make the program read from stdin.
>> I would use a -h option for help text and with no arguments it should read
>> from stdin .
>>
> That's unacceptable to me.

Then, it seems, that you are at odds with the Unix convention. Which is more
important to your users: consistency between the multitude of commandlines,
based on Unix conventions, or consistency between the few programs you source,
using conventions not "sanctioned" by Unix convention?

> My users will expect that when they see a program
> and type the name, it will either launch a GUI or print out. a brief message
> saying what the program is and what it does.
>>
>> > So do you pass an option
>> >
>> > myprogram -stdin
>> >
>> > or what is the normal way of solving this?

myprogram -

>> - (a single dash) as argument. Even if the programme accepts multiple file
>> name arguments , a single dash among those means "read from stdin".
>>
> So conventionally the file name is "-"?

No. conventionally, the '-' stands in for "read from the existing stdin". The
'-' is not considered to be a filename (as in fopen("-","r") ).

--
Lew Pitcher
"In Skills We Trust"

Re: Piping to stdin

<20230813120541.594@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27566&group=comp.lang.c#27566

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Sun, 13 Aug 2023 19:09:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <20230813120541.594@kylheku.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
<ubb3nd$1sk6k$1@dont-email.me>
Injection-Date: Sun, 13 Aug 2023 19:09:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="162b5c51be233759ac9aee76427ac06c";
logging-data="2044463"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lm1FJmqhyMiF/zmo1lOXmUPU5CiRRVSA="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:OlOGDijtXe0CVoAfpJcyo0cPNuY=
 by: Kaz Kylheku - Sun, 13 Aug 2023 19:09 UTC

On 2023-08-13, Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
> On Sun, 13 Aug 2023 07:07:55 -0700, Malcolm McLean wrote:
>
>> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>>> [ Followup-To: comp.unix.programmer ]
>>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>>> > On Unix-lke systems, what is the convention for putting a program into a
>>> > mode where it accepts input from stdin?
>
> The Unix convention is that a program /defaults/ to accepting data on stdin.
> If the program can accept alternate input sources, then either
> a) specific commandline arguments are used to change the input source, or
> b) the input source is the last argument in the commandline argument list
> (POSIX/SUS suggests that, if the last argument is '-', then the program
> will revert back to accepting input from stdin)
>
>>> > Where the user invokes it directly, he'll normally want input from a file. So
>>> > the normal invocation would be
>>> >
>>> > myprogram myinput.txt
>>> >
>>> > But if he just types "myprogram" it should display brief help text.
>
> Yah, no. That behaviour is contrary to Unix convention. To get the help
> summary, the Unix convention is to add a specific argument flag (typically -h),
> to the commandline
>
This is fine for a utility that requires arguments.

GNU Coreutils mv:

$ mv
mv: missing file operand
Try 'mv --help' for more information.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Piping to stdin

<87zg2uiur8.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27567&group=comp.lang.c#27567

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Sun, 13 Aug 2023 20:53:47 +0100
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <87zg2uiur8.fsf@bsb.me.uk>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="15be0507bd94ab5f777620aae7a0c046";
logging-data="2057470"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196iPDY+Sx33UBhBs2b2oYUzqz8U9PCSfk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:jwqk5FKggCpr8ZFEQ2A48UUYaGM=
sha1:Zno8AmLqsLf/baJiDrOK0fIT1zw=
X-BSB-Auth: 1.d2d3b64d4046b1c24f77.20230813205347BST.87zg2uiur8.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 13 Aug 2023 19:53 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>> [ Followup-To: comp.unix.programmer ]
>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>> > On Unix-lke systems, what is the convention for putting a program into a
>> > mode where it accepts input from stdin?
>> > Where the user invokes it directly, he'll normally want input from a file. So
>> > the normal invocation would be
>> >
>> > myprogram myinput.txt
>> >
>> > But if he just types "myprogram" it should display brief help text. So we
>> > can't omit the filename to make the program read from stdin.
>> I would use a -h option for help text and with no arguments it should read
>> from stdin .
>>
> That's unacceptable to me. My users will expect that when they see a program
> and type the name, it will either launch a GUI or print out. a brief message
> saying what the program is and what it does.

(Context: an XML to CSV converter.)

Your Unix/Linux users probably expect something else. When I install
program xxx, my first action is "man xxx". Failing that, I try "xxx -h"
(or --help).

I have a few useful programs that clearly come from the world of Windows
and demand a file name either for input or for output. Fortunately,
Linux can deal with this situation because it offers /dev/stdin and
/dev/stout so pretty much any program can forced play nice in a
pipeline.

But to help things along, I'd suggest you (a) provide a -h (and/or
--help) flag that prints to stderr and then exits reading no input; (b)
interpret - as stdin (in an input position) and as stdout (where you
program expects an output file) as not everyone know about (or can
access) /dev/std{in,out}. I'd consider a -p (or --pipeline) flag that
turns off your default message and reads stdin and writes stdout.

--
Ben.

Re: Piping to stdin

<shbCM.170113$ens9.110112@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27570&group=comp.lang.c#27570

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Piping to stdin
Newsgroups: comp.lang.c
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <U4x2oQwlZ0Kk8WwnO@bongo-ra.co> <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com> <ubb3nd$1sk6k$1@dont-email.me> <20230813120541.594@kylheku.com>
Lines: 45
Message-ID: <shbCM.170113$ens9.110112@fx45.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 13 Aug 2023 20:45:12 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 13 Aug 2023 20:45:12 GMT
X-Received-Bytes: 2629
 by: Scott Lurndal - Sun, 13 Aug 2023 20:45 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
>On 2023-08-13, Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>> On Sun, 13 Aug 2023 07:07:55 -0700, Malcolm McLean wrote:
>>
>>> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>>>> [ Followup-To: comp.unix.programmer ]
>>>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>>>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>>>> > On Unix-lke systems, what is the convention for putting a program into a
>>>> > mode where it accepts input from stdin?
>>
>> The Unix convention is that a program /defaults/ to accepting data on stdin.
>> If the program can accept alternate input sources, then either
>> a) specific commandline arguments are used to change the input source, or
>> b) the input source is the last argument in the commandline argument list
>> (POSIX/SUS suggests that, if the last argument is '-', then the program
>> will revert back to accepting input from stdin)
>>
>>>> > Where the user invokes it directly, he'll normally want input from a file. So
>>>> > the normal invocation would be
>>>> >
>>>> > myprogram myinput.txt
>>>> >
>>>> > But if he just types "myprogram" it should display brief help text.
>>
>> Yah, no. That behaviour is contrary to Unix convention. To get the help
>> summary, the Unix convention is to add a specific argument flag (typically -h),
>> to the commandline
>>
>
>This is fine for a utility that requires arguments.
>
>GNU Coreutils mv:
>
>$ mv
>mv: missing file operand
>Try 'mv --help' for more information.

The GNU utilities don't necessarily follow the POSIX guidelines, however.

Particularly with the verbose option naming (eg. --help instead of -h).

Any application that has more than 52 options should be split into
multiple applications or use a different configuration mechanism
(e.g. a configuration file).

Re: Piping to stdin

<EjbCM.170114$ens9.58966@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27573&group=comp.lang.c#27573

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Piping to stdin
Newsgroups: comp.lang.c
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <U4x2oQwlZ0Kk8WwnO@bongo-ra.co> <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com> <87zg2uiur8.fsf@bsb.me.uk>
Lines: 69
Message-ID: <EjbCM.170114$ens9.58966@fx45.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 13 Aug 2023 20:47:32 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 13 Aug 2023 20:47:32 GMT
X-Received-Bytes: 3608
 by: Scott Lurndal - Sun, 13 Aug 2023 20:47 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>
>> On Sunday, 13 August 2023 at 14:55:57 UTC+1, Spiros Bousbouras wrote:
>>> [ Followup-To: comp.unix.programmer ]
>>> On Sun, 13 Aug 2023 06:42:17 -0700 (PDT)
>>> Malcolm McLean <malcolm.ar...@gmail.com> wrote:
>>> > On Unix-lke systems, what is the convention for putting a program into a
>>> > mode where it accepts input from stdin?
>>> > Where the user invokes it directly, he'll normally want input from a file. So
>>> > the normal invocation would be
>>> >
>>> > myprogram myinput.txt
>>> >
>>> > But if he just types "myprogram" it should display brief help text. So we
>>> > can't omit the filename to make the program read from stdin.
>>> I would use a -h option for help text and with no arguments it should read
>>> from stdin .
>>>
>> That's unacceptable to me. My users will expect that when they see a program
>> and type the name, it will either launch a GUI or print out. a brief message
>> saying what the program is and what it does.
>
>(Context: an XML to CSV converter.)
>
>Your Unix/Linux users probably expect something else. When I install
>program xxx, my first action is "man xxx". Failing that, I try "xxx -h"
>(or --help).

Here's an example of a currently distributed xml command line
utility:

XMLLINT(1) xmllint Manual XMLLINT(1)

NAME
xmllint - command line XML tool

SYNOPSIS
xmllint [--version | --debug | --shell | --xpath "XPath_expression" |
--debugent | --copy | --recover | --noent | --noout | --nonet |
--path "PATH(S)" | --load-trace | --htmlout | --nowrap |
--valid | --postvalid | --dtdvalid URL | --dtdvalidfpi FPI |
--timing | --output FILE | --repeat | --insert | --compress |
--html | --xmlout | --push | --memory | --maxmem NBBYTES |
--nowarning | --noblanks | --nocdata | --format |
--encode ENCODING | --dropdtd | --nsclean | --testIO |
--catalogs | --nocatalogs | --auto | --xinclude |
--noxincludenode | --loaddtd | --dtdattr | --stream | --walker
| --pattern PATTERNVALUE | --chkregister | --relaxng SCHEMA |
--schema SCHEMA | --c14n] {XML-FILE(S)... | -}

xmllint --help

DESCRIPTION
The xmllint program parses one or more XML files, specified on the
command line as XML-FILE (or the standard input if the filename
provided is - ). It prints various types of output, depending upon the
options selected. It is useful for detecting errors both in XML code
and in the XML parser itself.

xmllint is included in libxml(3).

OPTIONS
xmllint accepts the following options (in alphabetical order):

....

Re: Piping to stdin

<87r0o6mqme.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27575&group=comp.lang.c#27575

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Sun, 13 Aug 2023 17:09:29 -0700
Organization: None to speak of
Lines: 14
Message-ID: <87r0o6mqme.fsf@nosuchdomain.example.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<mc7CM.741128$GMN3.387092@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="bc618e44e086a302991f1b359b3157e4";
logging-data="2115086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Y+TliAP7ru2+lQ45m7+Ra"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:LkAV/dHGbiKXmzuraBD+1Zbt0Nc=
sha1:ovVhjNeZJH8YkCj+/dcvfLfmigc=
 by: Keith Thompson - Mon, 14 Aug 2023 00:09 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
[...]
> Most programs in unix will accept '-?' or '-h' or some other flag
> to indicate that usage information is to be printed. Many utilities
> will print usage information if the input arguments are not valid.

Most Unix programs don't use '-?' because '?' is a shell wildcard
character. If you happen to have files in the current directory named
"-x" and "-y", "myprogram -?" expands to "myprogram -x -y".

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Piping to stdin

<ubbua5$3hium$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27578&group=comp.lang.c#27578

  copy link   Newsgroups: comp.unix.programmer comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!1.us.feeder.erje.net!feeder.erje.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer,comp.lang.c
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 00:59:49 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ubbua5$3hium$1@news.xmission.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <U4x2oQwlZ0Kk8WwnO@bongo-ra.co> <f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com> <LtQSo3SOOU09AXJ1X@bongo-ra.co>
Injection-Date: Mon, 14 Aug 2023 00:59:49 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3722198"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 14 Aug 2023 00:59 UTC

In article <LtQSo3SOOU09AXJ1X@bongo-ra.co>,
Spiros Bousbouras <spibou@gmail.com> wrote:
....
>> So conventionally the file name is "-"?
>
>Yes.

Yes, but, as indicated, it is just that - a convention. The program has to
recognize it, and act accordingly. Note, incidentally, that it raises the
question of "What if the user actually has a file named '-' ?"

By the way, I wish to point out that, despite all the passion some here
have argued with, the idea that a program *must* read stdin if no args are
given, is a) not absolute and b) basically old-fashioned. The newer model
is, as Malcolm would like it to be, that running a program with no args
*should* generate a usage message. Among other things, the user should not
have to guess what the "help" option is. Is it -h, -?, --help, or something
else???

For example, consider "cat". As it is, if you run cat with no args, it
will copy stdin to stdout. That's the old-fashioned way - and, of course
that can't be changed (i.e., fixed) now, because of all the existing code
(scripts) that depend on it (and would break if it were changed). But if
"cat" were being designed today, it would probably require a '-' to make it
read stdin and, if run with no args, would display a usage message.

Note, incidentally, that if you run "cat" with no args from a shell prompt,
it will look like your computer has crashed, and you may be reaching for
the power cord. Programs can handle this by using the isatty() function;
and if stdin is a tty, can, at least, issue a prompt before reading from
stdin. Or, of course, they can throw a flag on the play and tell the user
that there is no point in reading input from the terminal (which is, in
fact, pretty much true for most programs). Some (but not many)
well-conceived modern programs do this.

--
I'll give him credit for one thing: He is (& will be) the most quotable President
ever. Books have been written about (GW) Bushisms, but Dubya's got nothing on Trump.

Tremendously wet - from the standpoint of water.

Re: Piping to stdin

<ubbugh$3hium$2@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27579&group=comp.lang.c#27579

  copy link   Newsgroups: comp.lang.c comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c,comp.unix.programmer
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 01:03:13 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ubbugh$3hium$2@news.xmission.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <mc7CM.741128$GMN3.387092@fx16.iad> <87r0o6mqme.fsf@nosuchdomain.example.com>
Injection-Date: Mon, 14 Aug 2023 01:03:13 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3722198"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 14 Aug 2023 01:03 UTC

In article <87r0o6mqme.fsf@nosuchdomain.example.com>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>scott@slp53.sl.home (Scott Lurndal) writes:
>[...]
>> Most programs in unix will accept '-?' or '-h' or some other flag
>> to indicate that usage information is to be printed. Many utilities
>> will print usage information if the input arguments are not valid.
>
>Most Unix programs don't use '-?' because '?' is a shell wildcard
>character. If you happen to have files in the current directory named
>"-x" and "-y", "myprogram -?" expands to "myprogram -x -y".

Indeed - and this is one of the many reasons why insisting on an option
(any option) to get help is a bad idea. Given that -? is kind of a
standard in the Windows world, many programs that get ported over to
Unix from Windows, will have this misfeature.

--
Modern Conservative: Someone who can take time out from demanding more
flag burning laws, more abortion laws, more drug laws, more obscenity
laws, and more police authority to make warrantless arrests to remind
us that we need to "get the government off our backs".

Re: Piping to stdin

<20230813200644.979@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27583&group=comp.lang.c#27583

  copy link   Newsgroups: comp.unix.programmer comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer,comp.lang.c
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 03:07:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20230813200644.979@kylheku.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
<LtQSo3SOOU09AXJ1X@bongo-ra.co> <ubbua5$3hium$1@news.xmission.com>
Injection-Date: Mon, 14 Aug 2023 03:07:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e46a56cd35364bd395dd3d3fbcbd4bf2";
logging-data="2281841"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DE+USYzJlT1HRLNDiGnE+gyn1GrErKmY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:BLi+mXo+zcZpfTUu1nxqfK9MwmA=
 by: Kaz Kylheku - Mon, 14 Aug 2023 03:07 UTC

On 2023-08-14, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <LtQSo3SOOU09AXJ1X@bongo-ra.co>,
> Spiros Bousbouras <spibou@gmail.com> wrote:
> ...
>>> So conventionally the file name is "-"?
>>
>>Yes.
>
> Yes, but, as indicated, it is just that - a convention. The program has to
> recognize it, and act accordingly. Note, incidentally, that it raises the
> question of "What if the user actually has a file named '-' ?"

Then they write a path to reference it which doesn't look like "-",
such as "./-".

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Piping to stdin

<ubc63c$3hlul$2@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27584&group=comp.lang.c#27584

  copy link   Newsgroups: comp.unix.programmer comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer,comp.lang.c
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 03:12:44 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ubc63c$3hlul$2@news.xmission.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <LtQSo3SOOU09AXJ1X@bongo-ra.co> <ubbua5$3hium$1@news.xmission.com> <20230813200644.979@kylheku.com>
Injection-Date: Mon, 14 Aug 2023 03:12:44 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3725269"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 14 Aug 2023 03:12 UTC

In article <20230813200644.979@kylheku.com>,
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>On 2023-08-14, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> In article <LtQSo3SOOU09AXJ1X@bongo-ra.co>,
>> Spiros Bousbouras <spibou@gmail.com> wrote:
>> ...
>>>> So conventionally the file name is "-"?
>>>
>>>Yes.
>>
>> Yes, but, as indicated, it is just that - a convention. The program has to
>> recognize it, and act accordingly. Note, incidentally, that it raises the
>> question of "What if the user actually has a file named '-' ?"
>
>Then they write a path to reference it which doesn't look like "-",
>such as "./-".

You know that - and I know that - but do they know that?

--

First of all, I do not appreciate your playing stupid here at all.

- Thomas 'PointedEars' Lahn -

Re: Piping to stdin

<ubc689$82p$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27585&group=comp.lang.c#27585

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.2001:470:30::a654:103!not-for-mail
From: fork...@panix.com (John Forkosh)
Newsgroups: comp.lang.c
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 03:15:21 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ubc689$82p$1@reader2.panix.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
Injection-Date: Mon, 14 Aug 2023 03:15:21 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="2001:470:30::a654:103";
logging-data="8281"; mail-complaints-to="abuse@panix.com"
User-Agent: tin/2.6.0-20210823 ("Coleburn") (NetBSD/9.3 (amd64))
 by: John Forkosh - Mon, 14 Aug 2023 03:15 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> On Unix-lke systems, what is the convention for putting a program
> into a mode where it accepts input from stdin? Where the user
> invokes it directly, he'll normally want input from a file.
> So the normal invocation would be
> myprogram myinput.txt
> But if he just types "myprogram" it should display brief help text.
> So we can't omit the filename to make the program read from stdin.
> So do you pass an option
> myprogram -stdin
> or what is the normal way of solving this?

Some programs just default to...
FILE *fopen(), *input=stdin, *output=stdout;
requiring options...
myprogram -i inputfile -o outputfile
to override the defaults and fopen() the specified file(s).
Then you can alternatively...
myprogram -i inputfile -o outputfile
or use redirection for one or both...
myprogram < inputfile > outputfile
or just directly read/write from/to stdin/stdout.
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )

Re: Piping to stdin

<20230813201038.114@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27587&group=comp.lang.c#27587

  copy link   Newsgroups: comp.lang.c comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c,comp.unix.programmer
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 04:00:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20230813201038.114@kylheku.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<mc7CM.741128$GMN3.387092@fx16.iad>
<87r0o6mqme.fsf@nosuchdomain.example.com>
<ubbugh$3hium$2@news.xmission.com>
Injection-Date: Mon, 14 Aug 2023 04:00:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e46a56cd35364bd395dd3d3fbcbd4bf2";
logging-data="2292814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aV1nW/ZBCDDgjSfNdnK9lxDf3VTGvX5E="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:D41wivMjvKwIE5Agj/jQ484p1eo=
 by: Kaz Kylheku - Mon, 14 Aug 2023 04:00 UTC

On 2023-08-14, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <87r0o6mqme.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>scott@slp53.sl.home (Scott Lurndal) writes:
>>[...]
>>> Most programs in unix will accept '-?' or '-h' or some other flag
>>> to indicate that usage information is to be printed. Many utilities
>>> will print usage information if the input arguments are not valid.
>>
>>Most Unix programs don't use '-?' because '?' is a shell wildcard
>>character. If you happen to have files in the current directory named
>>"-x" and "-y", "myprogram -?" expands to "myprogram -x -y".
>
> Indeed - and this is one of the many reasons why insisting on an option
> (any option) to get help is a bad idea. Given that -? is kind of a
> standard in the Windows world, many programs that get ported over to
> Unix from Windows, will have this misfeature.

Many command-line programs get ported to Unix from Windows?

Why don't they adjust their conventions?

/X /Y /Z /? is another convention; that one is smarter.

The system installation can arrange for the first three not
to be paths, and for /? not to match anything due to there
not being a one-character item in the root dir.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Piping to stdin

<ubcpj3$28035$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27591&group=comp.lang.c#27591

  copy link   Newsgroups: comp.unix.programmer comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nunojsi...@invalid.invalid (Nuno Silva)
Newsgroups: comp.unix.programmer,comp.lang.c
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 09:45:43 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <ubcpj3$28035$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<U4x2oQwlZ0Kk8WwnO@bongo-ra.co>
<f2044b26-5a38-493d-9ab9-906bf73b0499n@googlegroups.com>
<LtQSo3SOOU09AXJ1X@bongo-ra.co> <ubbua5$3hium$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7260ba103602f3698eb550cbf3285551";
logging-data="2359397"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187W/5gfE/GfG82hFxL8YXq"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Cancel-Lock: sha1:50FqPq4wQg38CBzZBT9KbIDddMY=
 by: Nuno Silva - Mon, 14 Aug 2023 08:45 UTC

On 2023-08-14, Kenny McCormack wrote:

> In article <LtQSo3SOOU09AXJ1X@bongo-ra.co>,
> Spiros Bousbouras <spibou@gmail.com> wrote:
> ...
>>> So conventionally the file name is "-"?
>>
>>Yes.
>
> Yes, but, as indicated, it is just that - a convention. The program has to
> recognize it, and act accordingly. Note, incidentally, that it raises the
> question of "What if the user actually has a file named '-' ?"
>
> By the way, I wish to point out that, despite all the passion some here
> have argued with, the idea that a program *must* read stdin if no args are
> given, is a) not absolute and b) basically old-fashioned. The newer model
> is, as Malcolm would like it to be, that running a program with no args
> *should* generate a usage message. Among other things, the user should not
> have to guess what the "help" option is. Is it -h, -?, --help, or something
> else???

If you consider acceptable a convention of showing usage when no
arguments are given, then why not a convention on what to call the help
option?

I'd also argue that there's what should be a more uniform way to get
documentation on utilities: the online manual. Or (seeing this was from
comp.lang.c) is this also about running on systems where there might be
no such manual facility?

--
Nuno Silva
(I'm not reading comp.lang.c, so it's possible I'm lacking some context)

Re: Piping to stdin

<87o7ja3rpp.fsf@fatphil.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27596&group=comp.lang.c#27596

  copy link   Newsgroups: comp.lang.c comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: pc+use...@asdf.org (Phil Carmody)
Newsgroups: comp.lang.c,comp.unix.programmer
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 12:20:50 +0300
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <87o7ja3rpp.fsf@fatphil.org>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<mc7CM.741128$GMN3.387092@fx16.iad>
<87r0o6mqme.fsf@nosuchdomain.example.com>
<ubbugh$3hium$2@news.xmission.com> <20230813201038.114@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="3b75e13a62fc21aed83b06f34f572f82";
logging-data="2375925"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196saGomBbXorBPICbH5OTp"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:85bZzy4QwAL2GB909AMhdKklb8I=
sha1:EHUwRx5ER0Tz7YuBmWuyD5aRDQc=
 by: Phil Carmody - Mon, 14 Aug 2023 09:20 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
> On 2023-08-14, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> In article <87r0o6mqme.fsf@nosuchdomain.example.com>,
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>scott@slp53.sl.home (Scott Lurndal) writes:
>>>[...]
>>>> Most programs in unix will accept '-?' or '-h' or some other flag
>>>> to indicate that usage information is to be printed. Many utilities
>>>> will print usage information if the input arguments are not valid.
>>>
>>>Most Unix programs don't use '-?' because '?' is a shell wildcard
>>>character. If you happen to have files in the current directory named
>>>"-x" and "-y", "myprogram -?" expands to "myprogram -x -y".
>>
>> Indeed - and this is one of the many reasons why insisting on an option
>> (any option) to get help is a bad idea. Given that -? is kind of a
>> standard in the Windows world, many programs that get ported over to
>> Unix from Windows, will have this misfeature.
>
> Many command-line programs get ported to Unix from Windows?
>
> Why don't they adjust their conventions?
>
> /X /Y /Z /? is another convention; that one is smarter.
>
> The system installation can arrange for the first three not
> to be paths, and for /? not to match anything due to there
> not being a one-character item in the root dir.

So if I want to grep case-insensitively for whole words, and have line
numbers printed with the matched lines - in other words, on the unix
version I'm doing ``grep -win ...'' - should my system installation
arrange for /win to not be a path?

Phil
--
We are no longer hunters and nomads. No longer awed and frightened, as we have
gained some understanding of the world in which we live. As such, we can cast
aside childish remnants from the dawn of our civilization.
-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/

Re: Piping to stdin

<87il9ilzzq.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27597&group=comp.lang.c#27597

  copy link   Newsgroups: comp.lang.c comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c,comp.unix.programmer
Subject: Re: Piping to stdin
Date: Mon, 14 Aug 2023 02:44:41 -0700
Organization: None to speak of
Lines: 40
Message-ID: <87il9ilzzq.fsf@nosuchdomain.example.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<mc7CM.741128$GMN3.387092@fx16.iad>
<87r0o6mqme.fsf@nosuchdomain.example.com>
<ubbugh$3hium$2@news.xmission.com> <20230813201038.114@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="bc618e44e086a302991f1b359b3157e4";
logging-data="2376054"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BPemSdzRFp68Z2Rn6Rg0p"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:I3nI4CD/RowqTh5/rDy9Ju/CM7A=
sha1:Wy1Ul051dbenS6d2gsV0eA9LfZU=
 by: Keith Thompson - Mon, 14 Aug 2023 09:44 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
> On 2023-08-14, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> In article <87r0o6mqme.fsf@nosuchdomain.example.com>,
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>scott@slp53.sl.home (Scott Lurndal) writes:
>>>[...]
>>>> Most programs in unix will accept '-?' or '-h' or some other flag
>>>> to indicate that usage information is to be printed. Many utilities
>>>> will print usage information if the input arguments are not valid.
>>>
>>>Most Unix programs don't use '-?' because '?' is a shell wildcard
>>>character. If you happen to have files in the current directory named
>>>"-x" and "-y", "myprogram -?" expands to "myprogram -x -y".
>>
>> Indeed - and this is one of the many reasons why insisting on an option
>> (any option) to get help is a bad idea. Given that -? is kind of a
>> standard in the Windows world, many programs that get ported over to
>> Unix from Windows, will have this misfeature.
>
> Many command-line programs get ported to Unix from Windows?
>
> Why don't they adjust their conventions?
>
> /X /Y /Z /? is another convention; that one is smarter.
>
> The system installation can arrange for the first three not
> to be paths, and for /? not to match anything due to there
> not being a one-character item in the root dir.

Having a program misbehave because there happens to be a one-character
item in the root directory is a bad idea. (For example, on Cygwin I
often make /c a symlink to /cygdrive/c for convenience.)

Also, some shells, either by default or depending on options, will print
an error message if a wildcard fails to match.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Piping to stdin

<758f0a4b-d8c9-44db-af3e-2c8ac1ff2354n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27604&group=comp.lang.c#27604

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:4e64:0:b0:63c:f602:f1d9 with SMTP id ec4-20020ad44e64000000b0063cf602f1d9mr108511qvb.8.1692010463099;
Mon, 14 Aug 2023 03:54:23 -0700 (PDT)
X-Received: by 2002:a63:b55e:0:b0:565:8280:eac5 with SMTP id
u30-20020a63b55e000000b005658280eac5mr1736003pgo.0.1692010462858; Mon, 14 Aug
2023 03:54:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 14 Aug 2023 03:54:22 -0700 (PDT)
In-Reply-To: <87il9ilzzq.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:8573:d932:32fc:94b3;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:8573:d932:32fc:94b3
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<mc7CM.741128$GMN3.387092@fx16.iad> <87r0o6mqme.fsf@nosuchdomain.example.com>
<ubbugh$3hium$2@news.xmission.com> <20230813201038.114@kylheku.com> <87il9ilzzq.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <758f0a4b-d8c9-44db-af3e-2c8ac1ff2354n@googlegroups.com>
Subject: Re: Piping to stdin
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Mon, 14 Aug 2023 10:54:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3582
 by: Malcolm McLean - Mon, 14 Aug 2023 10:54 UTC

On Monday, 14 August 2023 at 10:45:00 UTC+1, Keith Thompson wrote:
> Kaz Kylheku <864-11...@kylheku.com> writes:
> > On 2023-08-14, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> >> In article <87r0o6m...@nosuchdomain.example.com>,
> >> Keith Thompson <Keith.S.T...@gmail.com> wrote:
> >>>sc...@slp53.sl.home (Scott Lurndal) writes:
> >>>[...]
> >>>> Most programs in unix will accept '-?' or '-h' or some other flag
> >>>> to indicate that usage information is to be printed. Many utilities
> >>>> will print usage information if the input arguments are not valid.
> >>>
> >>>Most Unix programs don't use '-?' because '?' is a shell wildcard
> >>>character. If you happen to have files in the current directory named
> >>>"-x" and "-y", "myprogram -?" expands to "myprogram -x -y".
> >>
> >> Indeed - and this is one of the many reasons why insisting on an option
> >> (any option) to get help is a bad idea. Given that -? is kind of a
> >> standard in the Windows world, many programs that get ported over to
> >> Unix from Windows, will have this misfeature.
> >
> > Many command-line programs get ported to Unix from Windows?
> >
> > Why don't they adjust their conventions?
> >
> > /X /Y /Z /? is another convention; that one is smarter.
> >
> > The system installation can arrange for the first three not
> > to be paths, and for /? not to match anything due to there
> > not being a one-character item in the root dir.
> Having a program misbehave because there happens to be a one-character
> item in the root directory is a bad idea. (For example, on Cygwin I
> often make /c a symlink to /cygdrive/c for convenience.)
>
> Also, some shells, either by default or depending on options, will print
> an error message if a wildcard fails to match.
>
I've just coded in this line.

help = opt_get(opt, "-help -h -H --help /H -?", 0);

On systems which expand wildcards in the shell, you have to type xmltocsv "-?"
to trigger help with the question mark option. But on Windows it should work
fine. Of course if you have an Xml file named "H" in the root directory then you
are in trouble. But you can pipe it to stdin and convert it that way.

Pages:12345
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor