Dmalloc Logo
Home

Documentation
Downloads
Forums
Releases

Search this site:

Donations:
If dmalloc has saved you or your company time or money, please use your credit-card or PayPal account to donate to the cause.

Dmalloc Tutorial: 4.1 Using a Shell Alias with the Utility
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Using a Shell Alias with the Utility

The dmalloc program is designed to assist in the setting of the environment variable `DMALLOC_OPTIONS'. See section Environment Variable Name and Features. It is designed to print the shell commands necessary to make the appropriate changes to the environment. Unfortunately, it cannot make the changes on its own so the output from dmalloc should be sent through the eval shell command which will do the commands.

With shells that have aliasing or macro capabilities: csh, bash, ksh, tcsh, zsh, etc., setting up an alias to dmalloc to do the eval call is recommended. Bash, ksh, and zsh users should add the following to their `.bashrc', `.profile', or `.zshrc' file respectively (notice the -b option for bourne shell output):

 
function dmalloc { eval `command dmalloc -b $*`; }

If your shell does not support the command function then try:

 
function dmalloc { eval `\dmalloc -b $*`; }

or

 
function dmalloc { eval `/usr/local/bin/dmalloc -b $*`; }

If you are still using csh or tcsh, you should add the following to your `.cshrc' file (notice the -C option for c-shell output):

 
alias dmalloc 'eval `\dmalloc -C \!*`'

This allows the user to execute the dmalloc command as `dmalloc arguments'.

Users of versions of the Bourne shell (usually known as /bin/sh) that don't have command functions will need to send the output to a temporary file and the read it back in with the "." command:

 
$  dmalloc -b arguments... > /tmp/out
$  . /tmp/out

By the way, if you are looking for a shell, I heartily recommend trying out zsh. It is a bourne shell written from scratch with much the same features as tcsh without the csh crap.

NOTE: After you add the alias to the file you need to log out and log back in to have it take effect, or you can execute the above appropriate command on the command line. If you enter dmalloc runtime and see any output with DMALLOC_OPTIONS in it then the alias did not work.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Gray Watson on May, 16 2007 using texi2html 1.76.

This work is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.
This page should be W3C Valid XHTML and should work with most browsers.