Article View: net.micro.atari16
Article #1615Re: Micro C-Shell: Megamax and IO redirection - query
From: Gert Poletiek
Date: Tue, 26 Aug 1986 08:28
Date: Tue, 26 Aug 1986 08:28
152 lines
6095 bytes
6095 bytes
In article <942@batcomputer.TN.CORNELL.EDU> braner@batcomputer.UUCP (braner) writes:
>[]
>
>Of greater annoyance to me is the fact that Megamax-compiled programs
>crash if IO is redirected from inside Micro C-Shell. The SAME
>program works fine if named PROG.TTP and invoked from the desktop,
>entering ">OUTFILE" into the dialog box. This is an old problem,
>but I havn't heard from either company yet. (I don't know if it's
>Megamax or Beckemeyer's "fault"). Contrary to recent claims, it does
>not matter (from C-Shell) if I use ">outfile" or "> outfile".
>It never works - I get two balls with lighted fuses.
>
>Any solutions? Are the companies involved going to do something
>about it? The products (Micro C-Shell and Megamax C dev. system)
>are generally excellent, and sales of both would gain if they'd
>work together better.
>
>- Moshe Braner
>
>Corson Hall, Cornell Univ., Ithaca NY 14853 (607) 272-3487
The fault is with Megamax, not Beckemeyer. Its even more strange
because Magamax manuals frequently refer to the Beckemeyer shell as an
alternative to their useless 'graphic shell'; an even worse imitation of the
Gem Desktop.
What happens is the following.
The Megamax compiler treats the function main as a special case, and if it
sees any arguments in its function header, it generates a reference to an
external label called _initargcv. If no argumenents to main are found, then
the compiler generates a global label _initargcv in the module containing
main, and it consists only of an RTS instruction.
So the problem arises in the _initargcv in the SYSLIB library.
What _initargcv does is the following:
It initializes the argv, argc variables (At Megamax they sure don't read the
GemDos manuals: they don't initialize the **envp pointer). When the
_initargcv routine comes across an argument line token starting with
'>' , '<' or '>>' they do their own crazy i/o redirection.
The i/o redirection in Megamax works as followes:
Megamax probably didn't like GemDos' not opening a standard error file,
and therefor desided to do it themselves. GemDos DOES open standard input
and output though, even the filedescriptor numbers of those two files are the
same as in unix, (0 and 1), but the filedescriptor 2 is missing (that one
refers to the RS232 port, Sigh). If you write a short program with Megamax
that prints out the filedescriptor numbers of stdin,out and err, you will see
the following numbers appear on the screen:
-32000
-32000
-32000
Now every time you do a read or a write your filedescriptor is compared with
-32000 (SPEED!!!). _Initargcv will substitute the -32000 with a REAL gemdos
file descriptor if the commandline from the DESKTOP (not the Beckemeyer
shell) contains one of the redirection characters.
I came across this bug when writing my own C-shell, that does the io
redirection BEFORE the commandline is passed to the program called. I do the
i/o redirection with the gemdos equivalents of the UNIX systecalls dup and
dup2, the same way i think as the Beckemeyer shell does the io redirection.
Shortly I will post the follwing to this newsgroup:
- Newly coded _initargcv to accomplish REAL io redirection, at the price
of loss of the standard error channel.
- Code to catch the Gemdos kill character (^C), which is less trivial
because Megamax produces position independent code.
- A prerelease of my idea of a handy C-shell like command interpreter,
(in about a month from now) that will include
(at least) the follwing features:
- real io redirection
- shell script execution (batch.ttp can be thrown away),
including parameter passing to shell scripts.
- aliasing
- shell variables
- history mechanism
- real UNIX pathnames (as the backslash will be the escape character)
-Commands:
alias define a shorthand
cat list a file
cd change working directory
chmod change file flags
clear clear the screen
cmp compare files
cp [-f] copy a file
date get / set date and time
df show free space on drive
diff get file differences
echo [-n] print arguments
history see previous commands
logout exit from GP-shell
lpr send to line printer
ls [-lt] show files
mkdir create a directory
more list a file
mv [-f] rename or move a file
od [-coh] dump file
pwd working directory name
read read variable
rm [-i] delete file
rmdir [-i] delete a directory
set set/show shell variable
touch update file time & date
unalias undefine a shorthand
unset clear shell variable
- internal variables:
color to set the screen color (now black or white)
blink set the cursor blink rate
delay set initial keyboard delay
repeat set keyboard repeat speed
path search path
home home directory
prompt your personal prompt
ignoreeof control-D acceptance as logout
(the first four vars will render the control panel useless)
If anybody has additional ideas for commands and the like, tell me,
and i will include it.
(This shell is not a port of any existing shell, and was written for
the ST in the first place)
Gert Poletiek
Dutch National Institute for High Energy Physics
Amsterdam
The Netherlands
Technical Details
Message-ID:
<200@nikhefh.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!nikhefh!gertReferences:
<93@uwmacc.UUCP> <202@vlsvax1.UUCP> <209@bridge2.UUCP> <942@batcomputer.TN.CORNELL.EDU>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!nikhefh!gert From: gert@nikhefh.uucp (Gert Poletiek) Newsgroups: net.micro.atari16 Subject: Re: Micro C-Shell: Megamax and IO redirection - query Message-ID: <200@nikhefh.UUCP> Date: Tue, 26-Aug-86 04:28:19 EDT Article-I.D.: nikhefh.200 Posted: Tue Aug 26 04:28:19 1986 Date-Received: Wed, 27-Aug-86 10:13:47 EDT References: <93@uwmacc.UUCP> <202@vlsvax1.UUCP> <209@bridge2.UUCP> <942@batcomputer.TN.CORNELL.EDU> Reply-To: gert@nikhefh.uucp (Gert Poletiek) Organization: NIKHEF-H Amsterdam (the Netherlands) Lines: 151 Apparently-To: rnews@mcvax