<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gbos.git/usr/nc.c, branch master</title>
<subtitle>gbos - a tiny Unix-flavored OS for the Game Boy Color (kernel, shell, coreutils in C, RAM filesystem)</subtitle>
<id>https://git.sl0p.foo/gbos.git/atom/usr/nc.c?h=master</id>
<link rel='self' href='https://git.sl0p.foo/gbos.git/atom/usr/nc.c?h=master'/>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/gbos.git/'/>
<updated>2026-09-22T14:02:55Z</updated>
<entry>
<title>usr: grep, more, cp, nc - and make pollcon pump the link</title>
<updated>2026-09-22T14:02:55Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-09-22T14:02:55Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/gbos.git/commit/?id=43e43b6dcec29e2b008d20135f5d02523b62fbcf'/>
<id>urn:sha1:43e43b6dcec29e2b008d20135f5d02523b62fbcf</id>
<content type='text'>
The shell has had pipes for a while with nothing to pipe *through*, and
an 18-row screen with no way to stop output scrolling off it.

- grep [-vin] PAT [file]: substring match (no regex), stdin or a file,
  grep(1)'s exit convention. The other end of the pipe, at last.
- more [file]: pages 17 lines at a time, --More-- bar in white-on-blue,
  any key pages, q quits. Counts *screen* rows, so wrapped lines pay
  their real cost. Keys come from pollin/pollcon, not stdin, so
  `cat big | more` still has a keyboard.
- cp SRC DST: the fs has rm/mkdir but no way to duplicate a file. mv is
  this plus rm (there is no rename). Rejects SRC == DST, which would
  otherwise truncate the source via O_WRITE before reading a byte.
- nc [-s] HOST PORT: raw TCP. Interactive (START sends the line with a
  CRLF, /q quits) or -s to pump stdin and print the reply with its own
  wall-clock idle timeout, because the kernel's blocking recv counts
  pumps, not seconds. Generalizes what chat/irc hardcode:
  `nc towel.blinkenlights.nl 23` works.

sys_pollcon now pumps the link before draining the console ring. The
ring is filled *by* net_pump, so a program that never touches the
network polled a ring nothing would ever fill: host-injected keys
(gbtype/gbdemo) hung `more` forever, and the Game Boy stopped answering
pings for as long as it ran. KGetc already pumps for this reason.

New tools take banks 35-38. Locals over statics in all four: a program's
_DATA starts at $A000, where the shell leaves the command line.
</content>
</entry>
</feed>
