🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs
Article #243

Re: CSH `...` purposeful on first word; EVAL bugs explained

#243
From: idallen
Date: Mon, 23 Jul 1984 14:44
32 lines
2076 bytes
The C Shell is designed to do the first "word" of the input as a
separate entity from the rest of the arguments, so if you type

    `command` arg1 arg2 arg3

you can be sure that `command` will expand to at most one word and
your supplied arguments will still be numbers 1, 2 and 3 to that
command.  It isn't hard to rewrite that a part of the shell to remove
this restriction, but you have to decide if you really want to change it.

As pointed out, giving the command to the EVAL built-in will remove
the restriction for you, but you have to be careful of the other CSH
bug where redirection of I/O and pipes are ignored for the first
command inside the EVAL, e.g.:

    eval "who|sort"     # the sort is ignored; WHO appears on tty
    eval "who" |sort    # this works
    eval "date >x"      # the ">x" is ignored; DATE appears on tty
    eval "date" >x      # this works
    eval "date|who|sort"# the pipe between date|who is ignored; who|sort works
    eval "date|who >x"  # the pipe between date|who is ignored; who >x works
    eval "date|users >x;echo hi" >y
       # DATE goes to Y, USERS to X, and HI to the tty (!)

This is because the EVAL built-in doesn't preserve and redo its file
descriptors for the commands it's about to execute.  I have a fix; but,
it's in with my other 20 pages of C Shell bug descriptions.  You'll
know you got the fix right if this works:

   echo "eval 'who|sort' | grep tty" | eval `cat` >xxx
-- 
        -IAN!  (Ian! D. Allen)      University of Waterloo
Technical Details
Message-ID: <8415@watmath.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!idallen
References: <492@masscomp.UUCP>, <21700001@smu.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!idallen
From: idallen@watmath.UUCP
Newsgroups: net.bugs
Subject: Re: CSH `...` purposeful on first word; EVAL bugs explained
Message-ID: <8415@watmath.UUCP>
Date: Mon, 23-Jul-84 10:44:11 EDT
Article-I.D.: watmath.8415
Posted: Mon Jul 23 10:44:11 1984
Date-Received: Tue, 24-Jul-84 04:16:04 EDT
References: <492@masscomp.UUCP>, <21700001@smu.UUCP>
Organization: U of Waterloo, Ontario
Lines: 32