[erlang-questions] "-noshell" on R9C
Peter Lund
erlang@REDACTED
Tue Apr 3 19:02:21 CEST 2007
Yes, that was it!!
It works better with
io:get_chars('',1).
or with
file:read(group_leader(),1).
I guess that it would be good if OTP added a io:get_chars/1 where only
the number of chars are specified to make the API simplier to use. :)
/Peter
Oscar Hellström skrev:
> On Tue, 03 Apr 2007 17:11:58 +0200
> Peter Lund <erlang@REDACTED> wrote:
>
>
>> Trying to use io:print_chars/1 on R9C in combination with unix pipesand
>> the "-noshell" option on a new MacOS X machine.
>>
>> Does anyone perhaps know why I get "[]" before each character below?
>>
>
> The [] are actually part of your prompt. "" is the same thing as an
> empty list, try to use the '' atom instead.
>
>
>> $ erlc myprint.erl
>>
>> $ cat test.txt
>> My example text.
>>
>> $ cat test.txt | erl -noshell -run myprint print
>> []M[]y[] []e[]x[]a[]m[]p[]l[]e[] []t[]e[]x[]t[].[]
>> []Num chars 17
>>
>> $ cat myprint.erl
>> -module(myprint).
>>
>> -export([print/0]).
>>
>> print() -> print(get_char(),0).
>>
>> print(eof,N) ->
>> io:format("Num chars ~p\n",[N]),
>> halt();
>> print(C,N) when is_integer(C) ->
>> io:put_chars([C]),
>> print(get_char(),N+1).
>>
>> get_char() ->
>> case io:get_chars("",1) of
>> eof -> eof;
>> [C] -> C
>> end.
>> $
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
More information about the erlang-questions
mailing list