9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Lyndon Nerenberg <lyndon@orthanc.ca>
To: 9front@9front.org, Steve Simon <steve@quintile.net>
Subject: Re: [9front] patch ssh.c extract window resolution
Date: Tue, 02 Feb 2021 14:06:37 -0800	[thread overview]
Message-ID: <1efc0fc214467d1e@orthanc.ca> (raw)
In-Reply-To: <F21E562F-AE1C-4CD7-B2CC-B48E3AA46C81@quintile.net>

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

> this means the environment variables ssh expects from vt dont exist. as =
a re=3D
> sult some unix apps like ls and man don=3DE2=3D80=3D99t format their out=
put correc=3D
> tly. this patch allows them to work as expected

In my UNIX .env (only sourced for "interactive" shells), if $TERM
is unset I set TERM=3Ddumb, PAGER=3D'col -b', and EDITOR=3Ded.  That seems
to get around most of the terminal-related issues.  And if you need
more than 80 columns of output, setting cols via stty(1) will take
care of that for programs that pay attention.

I also have a tiny UNIX program that prints column rulers, to help
with this sort of thing.

--lyndon

[-- Attachment #2.1: Type: text/plain, Size: 380 bytes --]

from postmaster@1ess:
The following attachment had content that we can't
prove to be harmless.  To avoid possible automatic
execution, we changed the content headers.
The original header was:

	Content-Type: text/x-c; name="ruler.c"; charset="us-ascii"
	Content-Description: ruler.c
	Content-Disposition: attachment; filename="ruler.c"
	Content-Transfer-Encoding: quoted-printable

[-- Attachment #2.2: ruler.c.suspect --]
[-- Type: application/octet-stream, Size: 874 bytes --]

/* ruler [cols] -- print a column-count ruler */

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>

int
main (int argc, char **argv)
{

	int cols, rows, i, j, skip;
	char *buf, *p;

	cols = -1;
	if (argc > 1) {
		cols = atoi(argv[1]);
		if (cols == 0)
			exit(1);
	}
	if (cols == -1) {
		struct winsize ws;
		if (ioctl(0, TIOCGWINSZ, &ws) == -1)
			exit(1);
		if (ws.ws_col > 0)
			cols = ws.ws_col;
	}
	if (cols <= 0)
		cols = 80;
		
	buf = malloc(cols + 1);
	if (buf == NULL) {
		fprintf(stderr, "out of memory");
		exit(1);
	}

	rows = log10(cols);
	for (i = rows; i >= 0 ; i--) {
		skip = pow(10, i);
		p = buf;
		for (j = 1; j <= cols; j++) {
			if (j % skip)
				*p++ = ' ';
			else
				sprintf(p++, "%d", (j / skip) % 10);
		}
		buf[cols] = '\0';
		printf("%s\n", buf);
	}
	exit(0);
}

  reply	other threads:[~2021-02-02 22:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 11:39 Steve Simon
2021-02-02 18:24 ` kvik
2021-02-02 19:56   ` Steve Simon
2021-02-02 22:06     ` Lyndon Nerenberg [this message]
2021-02-02 21:09   ` ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1efc0fc214467d1e@orthanc.ca \
    --to=lyndon@orthanc.ca \
    --cc=9front@9front.org \
    --cc=steve@quintile.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).