Shell enhancements for command arg checking

utzoo!decvax!ucbvax!mhtsa!harpo!npois!houxi!ihnss!ihuxs!steffen utzoo!decvax!ucbvax!mhtsa!harpo!npois!houxi!ihnss!ihuxs!steffen
Fri Mar 19 15:17:05 AEST 1982


There was a discussion a while back about passing the unprocessed command
line from the shell to the command so rm could check for * and warn that you
are removing all files.  I've noticed other commands that require input or
output file args to do checks that you aren't overwriting files (diffmk for
example).  It's annoying to have to use a temporary file instead of a pipe
just so a check like this can be made.  All commands should allow stdout and
make an output file arg optional.  Similarly all commands should read
stdin if there isn't an input file arg.  You should be able to pipe lex and
yacc output directly into cc instead of using a temporary file.  Cc could
assume that the pipe input is a C file because there are few assembler
source files and it's unlikely you would want to pipe an object file to cc.

My suggested solution to allowing file name checks in commands like cat and
diffmk is to have the shell set variables STDIN, STDOUT, and STDERR to the
redirected file names, if any.  These wouldn't be exported.

It would be nice if the shell could save the original command args and set
ARGC, ARG1, etc., but it would be hard to save this info for each command on
a multi-command input line.  The entire line could be saved and var INPUT
could be set to it, but this wouldn't be very useful because each command
would have to parse the line into words, hunt for its command name, and try
to determine how many of the next words are its args.  I suppose you could
write a library routine like getarg(3) that does most of the work.

				Joe Steffen
				Bell Labs, Indian Hill
				(312) 979-5381
				UUCPnet: ucbvax!ihnss!ihuxs!steffen



More information about the Comp.unix.wizards mailing list