Article View: comp.sys.amiga.tech
Article #737Shell command line passing
From: Michael Richardson
Date: Sat, 05 Aug 1989 01:20
Date: Sat, 05 Aug 1989 01:20
108 lines
5065 bytes
5065 bytes
In message <42700020@m.cs.uiuc.edu> Steve March writes:
>My question: How does one pass a command line to the shell and then have
>the shell parse and execute it?
Such a simple request! I can't answer it. I tried for weeks to
figure out why the Manx fexecv() (kindly left out in my edition
of the Manual. Identical to the exec() functions. Except that
it returns. error code is available by calling wait(). Sort of neat.)
wouldn't let me change pr_CIS to redirect stdin. I gave up and
created something called Rogue Start based on Peter da Silva's launch
code.
While everyone else is comparing Unix and AmigaDOS philosophy, I
think I will add my own:
(dawning Titanium-alloy armour with internal oxygen rebreather,
cold fusion power pack with an Elven Cloak to cover it all.)
Unix is a real beast. Anyone who has seen the configuration
of Sun's 386i or knows of the lovely fence jumping SVR3.2 386
people do understands this. Unix is, I'd guess, bigger and more complex now
than Multics, the OS whose hatred inspired K&R.
AmigaDOS, (or rather, Exec) is by contrast, quite a small efficient
streamlined OS, which doesn't at this time support virtual memory.
(Soon, right V.. Ooops I'm not supposed to mention that.)
Pre-VM Unixes were quite similar in many ways.
However, AmigaDOS proper, doesn't share one important thing
in common with Unix. - Policy -
Unix has no policy. Do what you like. If it turns you on to
make all of /usr/bin executable by others, but not members of
group staff (to which all users belong) then that is YOUR perogative.
If you really despise /bin/sh, don't use it. (Whether one
can realistically do that with the heavy use of scripts is debatable.
However, not having a C compiler also means you can't compile any C
programs. sh compilers do exist if you don't even want /bin/sh
online)
If you don't like using ^H for the erase character, (talk
to rms) then you don't.
AmigaDOS on the other hand, incorporates policy into every
part of it --- starting with the BSTR (what strings longer
than 255 characters? No, no will want to do that...) Oh what
if the command line is longer that that? Oh, not to worry,
we'll just make sure that there aren't any programs that can
accept more than 1 or 5 or 10 arguments. What about wildcards?
Okay. That'll solve the number of arguments problem! We put them
in the command. Noone will need to pass more than one wildcard or
more than one parameter!
Now what happens when I want to invoke a process?
I can Execute(cmd,fh_of_script_file_usually_null,stdout) it.
What happens if cmd comes from my command line? Like in
executecmd "echo Hi there"
After MY startup code has dealt with the " what does cmd
equal? "echo Hi there" right? Okay, now I pass this to
Execute() right? So echo gets "hi" and "there" -- guess what it
says?
4 points to anyone who said
"Echo: Bad Positional Argument" (admitedly, this is Arp. I haven't
checked the real 1.3 stuff.)
Okay. So how do I do this? (I was going to quote code, but I'll
shutup faster than that.) It turns out that I need to enclose each
argument that I got in "" to avoid having it broken up when
echo comes up.
Now what about failure codes? (I leave that as excersize for
the student. :-) Those with WShell please keep quite.)
I once brought up the fact that the CLI (Shell, ArpShell, WShell) are
not a user level process. They are part of AmigaDOS. They are NOT
shells. I was told that no, they are. The interface between them
and AmigaDOS just isn't well defined. But the whole point of
having a DOS at all is so that the user can have it load and
start running a program. How should they do that? With a program of
course. Which is loaded because the user asked DOS to run it for them,
which was loaded because....
(flame off)
Now don't get me wrong. I _DO_ do like passing messages (usefull
exceptions would be a good idea. More reliance on Semaphores
would help. Also, a Forbid()/Permit() pair for exceptions that was
used by CA= libraries would do the trick.) In fact I don't see a
way that intuition like things can be done well with messages.
In the end, Unix has to pass messages too. However, look at the
work that XDR has to do to get things like NFS going.
I also like user level file systems, and I understand that the BCPL
interface is going. (I don't care if AmigaDOS is written in C
or not. So long as the interface is.)
--
:!mcr!:
Michael Richardson Amiga
v--------+
UUCP: uunet!attcan!lsuc!nrcaer!julie!mcr | INTERNET mcr@doe.carleton.ca
Fido: Michael Richardson @ 1:163/109.10<--+ Alter @ 7:483/109.10
Technical Details
Message-ID:
<0356.AA0356@julie>Path:
arc1-ca.pugleaf.net!utzoo!dciem!nrcaer!julie!mcrShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dciem!nrcaer!julie!mcr From: mcr@julie.UUCP (Michael Richardson) Newsgroups: comp.sys.amiga.tech Subject: Shell command line passing Message-ID: <0356.AA0356@julie> Date: 5 Aug 89 01:20:53 GMT Organization: Sandleman Software Works' Debugging Department, Ottawa, ON Lines: 108