[erlang-questions] How do I prevent escript from reading stdin?

Jacob jacob01@REDACTED
Mon Jul 1 16:25:39 CEST 2019


Hi,

On 7/1/19 1:16 PM, Roger Lipscombe wrote:
> If I paste a sequence of commands into my terminal window...
>
>      ./some-escript
>      ./not-escript
>
> ...then not-escript never gets run, because (afaict), some-escript ate
> all of the input. If I paste the following:
>
>      ./some-escript </dev/null
>      ./not-escript
>
> ...then it's fine. But that's ugly.

While this might look ugly, it has the advantage of clearly showing your
intention, even if the escript was not consuming stdin. At least if you
put code like that into a script, it will help a future reader (possibly
including the writer) a lot.

When using bash/dash, you could also explicitly just close stdin
explicitly by

     ./some-escript <&-
     ./not-escript

with a similar effect but perhaps (depending on taste) less ugly. (Other shells may also have a similar feature)

Jacob




More information about the erlang-questions mailing list