The second is that DOS paths may include an optional drive name such
as C: and... the drive name has the colon character int. While Unix
uses the colon character to separate multiple components of the
search PATH, DOS could not do that: it had to pick a different
character, and it picked the semicolon. Take a look:
C:\>path
PATH=Z:\;C:\DEVEL\BIN;C:\DEVEL\DJGPP\BIN;C:\DEVEL\TC\BIN
The problem here is that many Unix applications, particularly shell
scripts like configure--especially configure--read the value of the
PATH variable and split it at colon separators or append to it by
adding a colon. But if we do these textual manipulations on a
DOS-style PATH like the one shown above... we'll get the wrong
behavior because of the drive names--and Unix programs don't know
they have to split on the semicolon instead and we cannot be expected
to fix them all.
The way DJGPP deals with this is by faking the /dev/ device tree.
While DJGPP provides implementations of things like /dev/null, it
also exposes DOS drives via their corresponding /dev/[a-z]/ virtual
directory. So, if you wanted to run applications that parse or modify
the PATH, you could rewrite the above as this:
PATH=/dev/z:/dev/c/devel/bin:/dev/c/devel/djgpp/bin:/dev/c/devel/tc/bin
This would allow any application reading the PATH to continue to
work. But note that this value doesn't seem to leave the realm of the
current process, which is interesting:
D:\>path
PATH=Z:\;C:\DEVEL\BIN;C:\DJGPP\BIN;C:\DEVEL\TC\BIN
D:\>
D:\>bash
bash-4.2$ echo $PATH
z:/;c:/devel/bin;c:/djgpp/bin;c:/devel/tc/bin
bash-4.2$ env | grep ^PATH=
PATH=z:/;c:/devel/bin;c:/djgpp/bin;c:/devel/tc/bin
bash-4.2$
bash-4.2$ PATH=/dev/c/djgpp/bin
bash-4.2$
bash-4.2$ echo $PATH
/dev/c/djgpp/bin
bash-4.2$ env | grep ^PATH=
PATH=c:\djgpp\bin
bash-4.2$
The picture above shows how bash sees a DOS-style PATH after it
starts. Manually setting it to a Unix path keeps the Unix path in the
current process (as shown by the built-in echo calls), but when we
spawn a different one (env is a separate executable), the value is
reset. This makes sense because, if we are running a regular DOS
program from within a DJGPP one, we want to export a DOS-compatible environment. Which means the Unix variants probably only stick within
shell scripts. You can also see how this works by peeking at
dosexec.c again.
But wait a minute... did I just show you bash?! On DOS? Oh yes, yes I
did...
# Trying it out yourself
It's time to get our hands dirty, try this out, and reminisce the old
days! Or, actually, not so old. You should know that DJGPP is still
available in this day and age and that it is quite up to date with
GCC 12.3--released less than a year ago.
First off, start by installing DOSBox. You can use the standard
DOSBox version, but it's probably better to go the DOSBox-X route so
that you can get Long File Name (LFN) support by setting the ver=7.1 configuration option. Otherwise, beware that running Bash later on
will create .bash_history under C:\ but the file will be named .BAS
due to some odd truncation, and this will later confuse Bash on a
second start and assume that .BAS is actually .bash_login.
<
https://www.dosbox.com/download.php?main=1>
<
https://dosbox-x.com/>
Now, pick a mirror for your downloads. You'll see various uses of FTP
in the list but don't be surprised if clicking on those doesn't work:
major browsers have unfortunately dropped their FTP client so you'll
have to "fall back" to an HTTP mirror.
<
https://www.delorie.com/djgpp/getting.html>
From there, you can use the Zip Picker to help you choose what you
need or you can download the same files I did:
* v2apps/csdpmi7b.zip: The CWSDPMI free DPMI host.
* v2apps/rhid15ab.zip: The RHIDE console IDE akin to Turbo C++.
* v2/djdev205.zip: Base DJGPP tools.
* v2gnu/bnu2351b.zip: GNU Binutils (tools like gas and objdump).
* v2gnu/bsh4253b.zip: GNU Bash.
* v2gnu/em2802b.zip: GNU Emacs.
* v2gnu/fil41br3.zip: GNU coreutils (tools like ls and cp).
* v2gnu/gcc930b.zip: GCC itself.
* v2gnu/gdb801b.zip: GDB because why not.
* v2gnu/gpp930b.zip: G++.
* v2gnu/grep228b.zip: grep because I find it very handy.
* v2gnu/mak44b.zip: GNU Make.
* v2gnu/shl2011br3.zip: Various shell utilities (*)
* v2gnu/txt20br3.zip: GNU textutils (tools like cat and cut).
(*) (like basename and dirname) that you'll almost-certainly need to
run shell scripts.
Once you have those files, create the "root" directory for what will
be the C: drive in DOSBox. I keep this under ~/dos/ and it is much
easier to prepare this directory from outside of DOSBox. Within that
location, create a djgpp subdirectory and unpack all the zip files
you downloaded into it. If there are any file conflicts, just tell
unzip to overwrite them.
Once the unpacking finishes, go to your DOSBox configuration. If you
are on Windows, you should have a start menu entry called "DOSBox
0.74-3 Options" or similar which opens the configuration file in
Notepad. If you are on Linux or any other reasonable OS, you can find
the configuration file under ~/.dosbox/. In the configuration, you'll
want to set up the C: drive at the very bottom of the file where the
[autoexec] section is. Here is what I do:
[autoexec]
MOUNT C C:\Users\jmmv\dos
SET PATH=%PATH%;C:\DJGPP\BIN
SET DJGPP=C:\DJGPP\DJGPP.ENV
C:
Launch DOSBox and you are set. Enter full-screen by pressing
Alt+Enter for the full retro experience and then... launch
bash:
C:\>gcc
gcc.exe: fatal error: no input files
compilation terminated.
C:\>bash
bash-4.2$ uname -a
MS-DOS #= Don't 5 00 i486 unknown
bash-4.2$ gcc
gcc.exe: fatal error: no input files
compilation terminated.
bash-4.2$ pwd
c:/
bash-4.2$ ls djgpp
allegro copying djgpp.env include libexec share
bin copying.dj faq info manifest tmp
contrib copying.lib gnu lib readme.1st
bash-4.2$ date
Sat Feb 10 11:09:51 GMT 2024
bash-4.2$ _
Pretty neat stuff, huh?
From: <
https://blogsystem5.substack.com/p/running-gnu-on-dos-with-djgpp>
--- SBBSecho 3.20-Linux
* Origin: End Of The Line BBS - endofthelinebbs.com (1:124/5016)