Shell
How the LainDOS prompt works after boot: built-ins, current directories, AUTOEXEC.BAT, PATH search, environment variables, and the small boundary where it intentionally stops short of COMMAND.COM compatibility.
From boot to A:\>
The shell is just another DOS program, but it is the user-facing control loop for the live image. It receives the initial PSP and environment, runs optional startup commands, then keeps handing child programs to EXEC until EXIT terminates it.
0102030405Startup and dispatch
SHELL.COM owns the prompt loop after boot.The kernel boots SHELL.COM like any other COM program. The shell immediately shrinks its allocation with AH=4Ah, prints LainDOS Shell, tries AUTOEXEC.BAT, and then enters the prompt loop.
Every interactive line is read with AH=0Ah, uppercased in-place, checked for a standalone drive switch, matched against the built-in command table, and finally passed to external command lookup.
Tests that pin this
Built-ins and current directory
Built-ins are small DOS API wrappers.The built-ins intentionally stay narrow. DIR lists the current directory with FindFirst/FindNext, formats entries like MS-DOS with fixed 8.3 columns, and supports /P pagination. CD, MD, and RD call the matching directory APIs. TYPE opens a file and copies it to handle 1.
The prompt and drive switches are DOS state, not private shell variables. The prompt asks AH=19h for the current drive and AH=47h for the current directory; C: uses AH=0Eh to select the drive and relies on the kernel to reject missing drives.
Tests that pin this
External command lookup
COM, EXE, and BAT are tried locally before PATH.If the command has no extension, the shell first tries .COM, then .EXE, then .BAT in the current directory. Only after those fail does it walk PATH for COM, EXE, and BAT candidates.
Arguments are copied to a PSPPSPThe DOS data block placed before each program, holding terminate vectors, the job file table, command tail, and environment pointer.-compatible command tail. Successful child programs return through AH=4Dh so the shell consumes the exit status and restores DS before printing the next prompt.
Tests that pin this
AUTOEXEC.BAT and batch lines
Startup batch is a simple straight-line script.run_autoexec just asks the batch runner to open AUTOEXEC.BAT. Missing files are ignored, which gives the same shell prompt on images without startup scripts.
Batch files are read into a fixed 512-byte buffer, split on CR/LF, uppercased, and executed through the same command path as interactive input. Empty lines are skipped; errors do not abort the script; nested batch files are rejected by batch_active.
Tests that pin this
PATH lookup
The shell reads PATH from its PSP environment.PATH lookup is deliberately caller-visible. The shell asks AH=62h for its PSPPSPThe DOS data block placed before each program, holding terminate vectors, the job file table, command tail, and environment pointer., follows PSPPSPThe DOS data block placed before each program, holding terminate vectors, the job file table, command tail, and environment pointer.:2Ch to the environment block, finds the PATH= string, and tries each semicolon-separated directory.
Commands that already contain a drive or slash bypass PATH. This keeps explicit paths deterministic while still allowing PATHRUN from A:BIN after the user changes into another directory.
Tests that pin this
Default environment
COMSPEC, PATH, PROMPT, and BLASTER are kernel-provided.The boot program gets an MCBMCBA 16-byte DOS memory header that describes the allocated or free block immediately after it.-backed environment before it starts. Default variables include COMSPEC=A:SHELL.COM, PATH=A:;A:BIN, PROMPT=$P$G, and the conventional Sound Blaster string used by game setup tools.
When the shell EXECs a child, the loader copies or writes an environment and appends the DOS executable-path tail. The environment tests read PSPPSPThe DOS data block placed before each program, holding terminate vectors, the job file table, command tail, and environment pointer.:2Ch and verify both the variables and the tail visible to child programs.
Tests that pin this
What this is not
LainDOS keeps shell behavior target-driven. The current shell is enough for test images, startup scripts, PATH-based game launchers, and manual emulator use, but it is not a full clone of COMMAND.COM.