Wrapping commands in scripts

You've come to this page because you've asked a question similar
to the following:

I am using the tail command (from
The OS/2 Command Line Utilities).
As the documentation says, it defaults, if I don't tell it otherwise, to
printing just one line. I want it to print the last hundred lines,
without, however, having to specify the /100 option every
time that I run it. How do I achieve this ?

One way to add options to every invocation of a command is to wrap it in a
command script of the same name. Just create a script named
tail.cmd and place it either in the same directory as
tail.exe itself or in a directory that is listed earlier in
the path than that directory.

If you are using JP Software's 4OS2 or
The 32-bit Command Interpreter, both
of which can vary the order in which extensions are searched, you must
also ensure that your PATHEXT environment variable specifies
that the command interpreter appends the .cmd extension
before it appends the .exe extension when searching for
files. You can always use another extension, such as .btm,
for the wrapper script filename if you need to.

The wrapped command is invoked with an explicit extension, in order to
prevent the wrapper script from invoking itself recursively, which it
would otherwise do if it just called "tail".

The script prepends /100 to the command tail except
when it sees that the command tail is /?. Because
/? may not be preceded by other options, that particular
command tail must be passed stright through to the wrapped command without
prepending anything.

One more thing to note:

If you prepend non-option arguments to
a command, you may well, depending from what the command is, alter the
default behaviour of the command. So be careful, and only do this if
it is what you really want.
For example: When invoked with no non-option arguments, the
tail utility itself reads from its standard input, enabling
it to be used in command pipelines. However, a wrapper script that always
prepended non-option arguments would result in this behaviour not occuring
when one invoked the tail command without arguments. This
could cause surprise if one were expecting to be able to use the
tail command as part of a command pipeline.