Re^2: Kernel Hacks & Weird Filenames
Kim Chr. Madsen
kimcm at ambush.UUCP
Fri May 13 19:29:05 AEST 1988
In article <56 at lazlo.UUCP> ccs at lazlo.UUCP (Clifford C. Skolnick) writes:
>This solution will also handle any control strings for the terminal. I
>wonder what "vi" would look like on his terminal :-). Many things
>would break if you put the stuff in the kernel tty driver, let's leave
>it in the "ls" or "cat" command. By the way, isn't there a Berkleyish
>type command "see" which does expand these things? I seem to remember
>"ls | see" from somewhere, maybe it was Xenix.
The program see is found under Xenix and as far as I remember also on
BSD Systems, in System V it's an option to cat "cat -v" (v for
visible) will display all control characters as ^<character> as in ^C,
and all characters with 8'th bit set as M-<character> as M-a (Meta-a).
If you're missing such feature on your particular system here is a PD
version of see, it has some restrictions however it strips 8'th bit
of every byte (easy to fix) and prints ~<character> for non-printable
characters. It was written for some Xenix III system which didn't
have the see command and look like another Xenix systems see command.
Regards,
Kim Chr. Madsen, AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte (Denmark)
UUCP: kimcm at ambush.dk, PHONE: +45 2424 111, FAX: +45 2423 090
Your old men shall dream dreams, your young men shall see visions.
-- The Bible, Joel, II:28
----------------------------CUT HERE--------------------------------
/*
* see - a program to view files containing non-printable characters.
*
* SYNOPSIS
* see [ file | - ] ...
*
* FORMAT OF OUTPUT
* See prints non-printable characters in the following order:
* 000 - 040 : As the corresponding control characters,
* preceeded by a caret '~'. Except the following
* LINEFEED : Printed as a newline.
* TAB : Printed as a TAB character.
*
* PROGRAMMED BY
* Kim Chr. Madsen
* Wed Mar 12 12:30:19 DNT 1986
*/
#include <stdio.h>
main(argc,argv)
int argc;
char *argv[];
{
int i;
FILE *f;
extern FILE *fopen();
extern void visual();
if (argc<2) {
visual(stdin);
exit(0);
}
for (i=1; i<argc; i++) {
if (strcmp(argv[i],"-") == 0) { /* stdin */
visual(stdin);
continue;
}
if ((f=fopen(argv[i],"r")) == (FILE *) NULL) {
perror(argv[i]);
continue;
}
visual(f);
fclose(f);
}
putchar('\n');
}
void visual(f)
FILE *f;
{
unsigned short c;
while((c=getc(f)) != EOF) {
c &= 0177; /* Cut MSB */
if (c<040) {
switch (c) {
case '\n':
putchar('\n');
break;
case '\t':
putchar('\t');
break;
default:
printf("~%c",c+'@');
break;
}
continue;
}
putchar(c);
}
}
More information about the Comp.unix.wizards
mailing list