Record of some of the computer tech I deal with so that it's documented at least somewhere.

Monday, 30 November 2009

4th isatty

Just encountered my first isatty annoyance.


% cat t
6 string buff
buff 5 accept . buff count type cr
buff 5 accept . buff count type cr
% echo ABCDEFabcdef | 4th cqx t
5 ABCDEF
-1
% # wtf?
% cat s
s" /fd/0" input open error? abort" no stdin!"
to fd0
fd0 use
6 string buff
buff 5 accept . buff count type cr
buff 5 accept . buff count type cr
% echo ABCDEFabcdef | 4th cqx s
5 ABCDEF
5 abcdef
% # more like it

1 comment:

The Beez' said...

Very dangerous what you're doing there. Once you're reading from a file, 4tH doesn't terminate the string anymore. You're relying on the zeros that were there when 4tH started.

The first behavior is explained because 4tH clears the input buffer from the vanilla stdin once it has read it. It would be annoying if a user typed in something, the program used the string partially and then the user was confronted with the trailing stuff left unread in the buffer.

In these cases, it is much better to use REFILL in connection with PARSE. Still, I wouldn't recommend it with binary data.. :-(