[comp.unix.wizards] Re^2: Kernel Hacks & Weird Filenames

kimcm@ambush.UUCP (Kim Chr. Madsen) (05/13/88)

In article <24@csnz.nz> paul@csnz.nz (Paul Gillingwater) writes:

>Does that mean that a naive user can make a file with a <SPACE>
>in the name?   e.g.   "John Doe" or "Job Cost" or other equally
>"intuitively correct" but WRONG names...:-)

Sure, why not if you want to:

	echo "Hello World" > "John Doe"

Will do the job nicely.

Why are you suggesting that such file-names are WRONG, they're not
normal, but they're absolutely correct.

Regards,

Kim Chr. Madsen, AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte (Denmark)
UUCP: kimcm@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

kimcm@ambush.UUCP (Kim Chr. Madsen) (05/13/88)

In article <56@lazlo.UUCP> ccs@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@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);
	}
}

kimcm@ambush.UUCP (Kim Chr. Madsen) (05/13/88)

In article <7869@brl-smoke.ARPA> gwyn@brl-smoke.ARPA (Doug Gwyn ) writes:

>Geez.  Haven't you heard of "pipes and filters"?  Pipe the output of "ls"
>into a filter that converts whatever your notion of unprintable characters
>may be into whatever you think the corresponding printable equivalent
>should be.  Don't try to muck around with the basic system kernel and
>utilities!

Come, come!

Don't be so hasty, some UNIX versions of ls doesn't even print the
filename correct if it contains control-characters or characters with
8'th bit set, but prints a '?' instead of these characters (obviously
in a well meant attempt to not screw-up the user's terminal).  If this
is the case a filter will have no way of guessing what funny character
caused the question-mark.  However such behaviour of ls should be
mocked with in order to make the novice user able to remove such a
file without assistance from a guru, or at least be able to know the
name of the file without having to resort to "od -c ."

Regards,

Kim Chr. Madsen, AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte (Denmark)
UUCP: kimcm@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

ccs@lazlo.UUCP (Clifford C. Skolnick) (05/15/88)

In article <758@ambush.UUCP> kimcm@ambush.UUCP (Kim Chr. Madsen) writes:
:
:Don't be so hasty, some UNIX versions of ls doesn't even print the
:filename correct if it contains control-characters or characters with
:8'th bit set, but prints a '?' instead of these characters (obviously
:in a well meant attempt to not screw-up the user's terminal).  If this
:is the case a filter will have no way of guessing what funny character
:caused the question-mark.

Hmm, if ls replaces the character with a '?' before printing, the kernal
tty driver will never have a chance to fool with the character anyway!
Perhaps you should not be so hasty!

:
:Kim Chr. Madsen, AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte (Denmark)
:UUCP: kimcm@ambush.dk, PHONE: +45 2424 111, FAX: +45 2423 090
-- 
Clifford C. Skolnick    | - Never insult 7 men while carrying a six shooter -
Phone: (716) 427-8046   |                       /!kodak!pcid!gizzmo! \
PACKET: N1DPH@WB2VPH    |  ...!rutgers!rochester                      lazlo!ccs
BITNET: CCS6277@RITVAX  |                       \!ritcv!ritcsh!sabin!/