On 2013-11-21 12:39, Marcin Zajączkowski wrote:
> On 2013-11-21 04:59, David Adam wrote:
>> On Thu, 21 Nov 2013, David Adam wrote:
>>> On Wed, 20 Nov 2013, Marcin Zajączkowski wrote:
>>>> How can I determine that my function has something to on read stdin (to
>>>> not call "read" then which would open an interactive prompt)?
>>>
>>> This is a different question; the tty function does not check for the
>>> presence or absence of data on stdin. I don't actually know of a clever
>>> way of doing this from a shell script; in C I guess you'd do a select()
>>> with a zero timeout or something.
>>
>> I've just been informed that (at least in bash) you can use `read -n 0 -t
>> 0`, but this is not implemented in fish at this stage.
>
> Thanks for your reply!
>
> I made a workaround in my function and first check if there are any
> params and later read from stdin which uses piped content or just the
> user for a text.
>
> Nevertheless it would be useful to have a way to tell read to fail
> immediately (and in my case display an error message to the user) when
> there is nothing on stdin, e.g. by using a simple switch. I created an
> issue:
> https://github.com/fish-shell/fish-shell/issues/1134

Ehh, I missed a part of the content of your first message when you 
provide a way with "if not tty" to determine when to read from stdin. In 
that case (a simple hacky workaround) my feature request is much less 
needed.

Marcin



------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to