Here is a link
to a Wikipedia page about the DOS Wedge.
The DOS Wedge "worked by altering BASIC's "CHRGET" subroutine ...
so that each character passing by the BASIC interpreter would be
checked for wedge commands, and the associated "wedged-in" routines run
SAM works by adding to the PATH variable and the environment in such
a way that a new, additional set of commands and functions are
"wedged-in". The original set of commands and functions remain,
but the new set is regarded as a menu--which includes commands that can
change the menu and return to a previous menu.