[comp.sys.amiga] Shell scripts on AmigaDOS & Unix

mwm@violet.berkeley.edu (Mike Meyer) (01/16/87)

I really like shell scripts. I wrote my first shell script for Unix
last decade. I've done accounting systems alomst entirely with awk,
sed and the shell.

I finally sat down and wrote a non-trivial CLI application for
AmigaDOS (see the Fish Index posting). I thought I'd comment on the
difference between them.

Firstly, and most obviously, pipes are relatively new things to
Tripos; or so I'd guess. The commands aren't written with the Unix
philosophy of expecting your output to go to another program. They're
cluttered with extraneous garbage (useful to look at, but not to
process). Also, the lack of a real stream editor was painfully
obvious, forcing me descend to C code at one point (trivial program,
but still.....).

On the other hand, that pipes exist in the AmigaDOS name space,
instead of being anonymous, is a MAJOR win. For instance, I've got one
invocation of edit that takes the file to be edited from one pipe, the
edit commands from a second, and puts it's output on a third. This is
NOT doable on Unix (if it is, *let me know how* - I've wanted to do
this type of things several times!). [Ok, I think I can see how to do
it, if you have either v8, or one of the /dev/fd hacks in your kernel.
May have to go try it....].

Obviously, this kind of thing could be added to Unix, and has in part
with the ever-popular /dev/stdin and /dev/stdout pseudo devices (from
v8; you can get source for it for either 4.2 or 4.3 from me). Sys V
may even have it in full; I'm not sure what "named pipes" constitute.
The query to my SysV wizard has gone out in the mail.

In summary, Unix is a nicer place to write shell scripts, because the
tool set has been designed for using pipes. It's also easier to start
a pipe from the shell (fixable by re-writing the shell for AmigaDOS,
of course!). If suitable tools got built for AmigaDOS, I think it'd be
better, just because pipes are in the file namespace. Oh, yeah - you
also get the equivalent of /dev/stdin and /dev/stdout on AmigaDOS for
free, in the filename "*".

One odd things is that the tools for the two systems should be
DIFFERENT. On Unix, everything should read from stdin by default, and
write to stdout by default. On AmigaDOS, since pipes are filenames,
you want things to have "from" and "to" filenames. Obviously, you can
make tools from Unix work in AmigaDOS by doing "tool >pipe:out
<pipe:in", or some such uglyness. If /dev/stdin & /dev/stdout are
implemented on your Unix systems, you can make the AmigaDOS tools work
by "source | tool from /dev/stdin to /dev/stdout | sink" Given the
existence of "*", I don't even see much point in having things default
to stdin or stdout; just type the two extra characters, and it works
(who does that map, anyway? AmigaDOS?). This explains the interface
for the detab command - it was designed to go with the rest of the
AmigaDOS tools; not to look like a Unix tool (though I stole the Unix
"useage" messages; they're a win compared to the template output from
the AmigaDOS stuff. If only you could convince Unix tools to give you
a useage message + real help with a '?'!).

Ok, that should be enough to make the Unix bigots start shouting :-).
Let's see what happens.....

	<mike

P.S. - my choices for two most needed programs on AmigaDOS: research
awk and a good sed. Anyone got one, or want to write one?

wagner@utcs.UUCP (01/19/87)

In article <2228@jade.BERKELEY.EDU> mwm@violet.berkeley.edu(Mike Meyer) writes:
>
>Firstly, and most obviously, pipes are relatively new things to
>Tripos; or so I'd guess.
>
>On the other hand, that pipes exist in the AmigaDOS name space,
>instead of being anonymous, is a MAJOR win.

Ok, it's late at night, and I'm sleepy, but I'm missing something here.
If pipes existed in AmigaDOS, I think it would be a major win, but I don't
seem to recall them ever existing.  Did I miss something in the enhancer
documentation?

Michael

mwm@eris.BERKELEY.EDU (Mike Meyer) (01/19/87)

In article <1987Jan19.022653.20521@utcs.uucp> wagner@utcs.UUCP (Michael Wagner) writes:
>In article <2228@jade.BERKELEY.EDU> I write:
>>Firstly, and most obviously, pipes are relatively new things to
>>Tripos; or so I'd guess.
>
>Ok, it's late at night, and I'm sleepy, but I'm missing something here.
>If pipes existed in AmigaDOS, I think it would be a major win, but I don't
>seem to recall them ever existing.  Did I miss something in the enhancer
>documentation?

Since this is the third inquiry I've seen about them, I expect that
either 1) I forgot to mention it entirely, or 2) I wasn't clear about
it. So let's do it here. The poop on pipes follows.

As far as I know, there is no PIPE: device on any version of AmigaDOS
sold by C/A.

Ok, you asks, so where did I get one?

Well, I'm running the PIPE: driver that comes on the MetaComCo ToolKit
disk. Goes in as documented, works as documented, and is worth it's
wait in RAM:. There are two other worthwhile things on the disk: the
AUX-CLI driver that lets you hang CLI's off the serial port, and a
dissasembler that works on AmigaDOS commands and library modules.  I'm
currently trying to do a Unix-like pipe() that won't die horrible
deaths on systems without pipe:'s for the mg shell command (among
other things - just to damn busy these days).

There is also a pipe: driver on some of the ToolKit disks distributed
with the beta (and gamma?) versions of 1.2. I've got one, but have
never used it.

	S'aright?
	<mike