[Gambas-user] auto detect pipe |

Jussi Lahtinen jussi.lahtinen at gmail.com
Wed Nov 1 14:38:37 CET 2023


No time to think, but I guess "if (isatty(STDIN_FILENO))" would work when
translated into Gambas. However, my gut feeling is that you are doing
something in non-standard way.
IE there should be another approach for the desired end result. Why do you
need this?


Jussi


On Wed, Nov 1, 2023 at 2:36 PM Bruce Steers <bsteers4 at gmail.com> wrote:

> i have made a command that supports piping using Application_Read()
>
> Static Public Sub Application_Read()
>
>   $bReading = True
>
>   While Lof(Last)
>     $aArgs[0] = Last.ReadLine()
>     ProcessString()
>     If Not Eof(Last) And If Not $bNewLine Then Print ""
>   Wend
>
>   $bReading = False
>
> End
>
> it works but i have added an arg -p that if i use -p then the pipe is read.
> Eg.
> echo "This text" | mycommand -p
>
> can i detect if a pipe is to be used or not automatically?
>
> Respects
> BruceS
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231101/71268186/attachment-0001.htm>


More information about the User mailing list