ref: 57dbe35fb68dda4888fc4c9e8c8d0b3106a8a21c
parent: 1bfde841484fadb1c41f41a6279e7e070f61a31b
author: cinap_lenrek <[email protected]>
date: Mon Dec 9 12:44:28 EST 2019
console(8): add console command and manpage the console command runs a command or the system shell under a new instance of kbdfs, optionally providing a serial console when $console environment variable is set.
--- /dev/null
+++ b/rc/bin/console
@@ -1,0 +1,16 @@
+#!/bin/rc
+
+if(~ $#* 0)
+ *=(rc -i)
+
+a=$console(1)
+if(! ~ $#a 0){
+ if(! ~ $a /* '#'*)
+ a=/dev/eia^$a
+ if(test -e /dev/kbd){
+ @{rfork ns; aux/kbdfs; exec $* </dev/cons >/dev/cons >[2=1]} | tee $a
+ exit
+ }
+}
+aux/kbdfs $a
+exec $* </dev/cons >/dev/cons >[2=1]
--- a/sys/man/8/kbdfs
+++ b/sys/man/8/kbdfs
@@ -1,6 +1,6 @@
.TH KBDFS 8
.SH NAME
-kbdfs \- keyboard and console filesystem
+kbdfs, console \- keyboard and console filesystem
.SH SYNOPSIS
.B aux/kbdfs
[
@@ -12,7 +12,7 @@
.B -m
.I mntpnt
] [
-.I filename
+.I consfile
]
.nf
@@ -24,6 +24,12 @@
.B /dev/kbin
.B /dev/kbmap
.fi
+.PP
+.B console
+[
+.I cmd
+.I args...
+]
.SH DESCRIPTION
.PP
Started on
@@ -81,6 +87,17 @@
otherwise on
.B /dev
(the default).
+.PP
+The
+.B console
+command executes
+.I cmd
+(defaults to the system shell)
+under its own
+.I kbdfs
+instance providing a serial console if
+.B $console
+environment variable is set.
.SS Console
.PP
Reading the
@@ -151,7 +168,7 @@
causes the characters to be printed on the console screen.
.PP
When a
-.I filename
+.I consfile
is passed to
.IR kbdfs (8)
as its last argument, it reads and processes the
@@ -158,7 +175,10 @@
characters from that file and forwards them to the
.BR cons
file with the same text processing applied as on keyboard input.
-This is used on serial consoles.
+This is used to provide a serial console when
+.B $console
+environment variable is set. (see
+.IR plan9.ini (8)).
.SS Keyboard
A read on the
.BR kbd
@@ -254,11 +274,14 @@
.IR cons (3),
.IR keyboard (6),
.IR utf (6),
-.IR kbd (3)
+.IR kbd (3),
+.IR plan9.ini (8)
.SH FILES
.B /sys/lib/kbmap/*
.SH SOURCE
.B /sys/src/cmd/aux/kbdfs
+.br
+.B /rc/bin/console
.SH HISTORY
.I Kbdfs
first appeared in 9front (May, 2011).