Dec 092017
DOS implementation of the UNIX ! (bang) command. Will allow you to recall the last 20 command line statements. ASM source included.
File BANG!.ZIP from The Programmer’s Corner in
Category Utilities for DOS and Windows Machines
DOS implementation of the UNIX ! (bang) command. Will allow you to recall the last 20 command line statements. ASM source included.
File Name File Size Zip Size Zip Type
BANG!.ASM 21618 4795 deflated
BANG!.DOC 6264 2756 deflated
BANG!.COM 1746 1261 deflated

Download File BANG!.ZIP Here

Contents of the BANG!.DOC file

Bang! - A Unix-like History for DOS
Copyright 1990 by Lawrence Kesteloot
Version 1.0 - August 26, 1990

Bang! is a memory-resident program which takes over DOS's GETSTRING
routine (INT 21h, Function 0Ah), and adds a history. For those not
familiar with UNIX (csh), a history is a list of the last 20 commands
entered from the command line which can be recalled in a number of ways.
The exclamation point is used to recall the old commands, and is
pronounced "bang".

In UNIX, the number 20 is variable, but in Bang! it is fixed to 20.
There are several ways to recall an old command:

1. You can type "!str" where "str" is the beginning of
a previous command. The string search is case-
sensitive and runs backward from the last command to
the oldest.
2. You can type "!n" where "n" is the history number of
the command to be recalled. You can find out the
history number of a command by simply pressing "!"
and , which will list the last 20 commands
along with their numbers.
3. You can type "!!" which recalls the last command.
This is somewhat the same as pressing , except
that your hands don't have to leave the keyboard to
go to the function keys.

In UNIX there are several more ways to recall old commands, but I felt
that the above three were used most. You can get instructions by
typing "!!!".

Here are some examples to demonstrate some other features of the program:

Let's say you type "!" and you get the following listing:

2 dir BANG*.*
3 cd \tc\code\bang
4 tasm bang!
5 tlink -t bang!

Typing: Would recall:
------- -------------
!! tlink -t bang!
!4 tasm bang!
!t tlink -t bang!
!ta tasm bang!
!c cd \tc\code\bang
!C CD \TP55\CODE (Note use of case-sensitive search)
!d /w dir BANG*.* /w (New parameter was ADDED)
!2 /p dir BANG*.* /p

The new, recalled commands are entered into the history as if they had
been typed. Note also that when there are more than 20 entries in the
history, the old history entries keep their numbers. For example,
after the 21st entry is added, the old entry #10 would stay #10, not
become #9. This allows you to refer to entries by number "!n" without
having to worry about the entries being re-numbered on you.

All commands typed which do not start with "!", except for blank lines,
are added to the history.

Do not run Bang! more than once in one session, because they will simply
add to each other (it does not check to see if it is already installed).

If Bang! is run with the /P parameter ("bang! /p"), then the current
history number is displayed just before the line is input from the user.
You may want to change your prompt from "$p$g" to "$p - $" or something,
which would give you a prompt like

C:\TC\CODE - 12>

This is useful in that if you want to recall a line which has not yet
scrolled off the screen, you can simply type "!12" or whatever number
is right next to it.

Bang! works even better with Stanley Reifel's "Norton DOS Editor", but
NDE must be loaded before Bang!. This combination allows you to use
both the ! commands and the arrow keys to edit. Although the arrow-key
method or the method might seem faster, it is actually slower
because your fingers have to leave the home keys to go to the function
keys or the cursor pad.

So there. Enjoy the program. Send me absolutely no money unless it's
a lot of it, but I would like to get suggestions or bug reports. Leave
a note for the SYSOP on the AMRAD BBS (703) 734-1387, or send some
mail to "[email protected]".


- Typing ^str1^str2^ would recall the last command and replace the
first occurence of str1 with str2.
- Typing !?str? would be the same as !str except that str would be
searched throughout the previous commands, not just the first
few letters.
- Typing !-2 would recall the entry two commands ago ("!-n" would
be a relative version of "!n")
- Another command-line switch would add a confirmation prompt.
In other words, the old history entry would be recalled, displayed
and the user could press to do it or to do nothing.
- Don't enter ERASE, DEL, or FORMAT commands into the history.

Let me know if you want to see any of the above.


I've included the code BANG!.ASM so you can learn from or improve it.
Thanks to Stanley Reifel who wrote NDE.ASM, from which I took the
framework for writing this TSR.

This is my first large assembly-language project, so please excuse my
confused and inconsistent programming style. If you see any mistakes
or bugs in the code, I'd like to hear of them, or if you can spot a
change for a speed-up or reduction in code size, that would be good
too although neither are really necessary in this program.

The program catches INT 21h. If the function is other than 0Ah
(GETSTRING), then it just passes everything onto DOS. If it is
0Ah, then it sets up the stack to simulate an INT. It then calls
DOS (the old INT 21h vector), and DOS's iret command actually returns
to Bang!. Bang! then parses the entered string and replaces it as
necessary. It then does its own iret, which returns control to the
program (COMMAND.COM in this case) which called the INT in the first

There were other ways of doing it, such as writing my own GETSTRING
routine, but this way was the simplest, and it also allows the user
to use programs like NDE at the same time.


I'm not responsible for any damage this program may cause, bodily or
otherwise, and all that other stuff. I can't really see how that might
happen, except if it accidentally recalls an ERASE command or something.

 December 9, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>