mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added $LINES and $COLUMNS to the shell.
This tests the fancy new system call tcgetwinsize(2).
This commit is contained in:
parent
143120d160
commit
12326f2e34
1 changed files with 15 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <errno.h>
|
||||
#include <error.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
|
||||
int status = 0;
|
||||
|
||||
|
@ -41,6 +42,19 @@ void updatepwd()
|
|||
setenv("PWD", wd, 1);
|
||||
}
|
||||
|
||||
void updateenv()
|
||||
{
|
||||
char str[128];
|
||||
struct winsize ws;
|
||||
if ( tcgetwinsize(0, &ws) == 0 )
|
||||
{
|
||||
sprintf(str, "%zu", ws.ws_col);
|
||||
setenv("COLUMNS", str, 1);
|
||||
sprintf(str, "%zu", ws.ws_row);
|
||||
setenv("LINES", str, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int runcommandline(const char** tokens)
|
||||
{
|
||||
int result = 127;
|
||||
|
@ -192,6 +206,7 @@ readcmd:
|
|||
}
|
||||
}
|
||||
|
||||
updateenv();
|
||||
char statusstr[32];
|
||||
sprintf(statusstr, "%i", status);
|
||||
setenv("?", statusstr, 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue