Shell escape

From NetHackWiki
Jump to: navigation, search

In game, the ! key triggers the shell escape. This should send you to a command line; exit the shell to return to NetHack. The exact behavior varies by operating system.

It only works if the person who compiled the game had SHELL defined in config.h. Persons who build the game for public servers or other environments in which the player should not reach a shell will disable it.

In the source code, the dosh function handles this. The code for this function, if any, is somewhere under the nethack-3.4.3/sys directory for your operating system.

The file nethack-3.4.3/sys/unix/unixunix.c contains the source for shell-escaping for a Unix system. If there is a SHELL environment variable, then NetHack will start that program, else NetHack will attempt to run /bin/sh. In most shells, the exit command will then return you to NetHack. Since most Unix now have job control, you could just press Ctrl + Z to suspend NetHack and return to the calling shell instead of starting a subshell; for that reason some players may never think to use the shell escape.

This page may need to be updated for NetHack 3.6.0.

It may contain text specific to NetHack 3.4.3. Information on this page may be out of date.

Editors: After reviewing this page and making necessary edits, please change the {{nethack-343}} tag to {{nethack-360}} or {{noversion}} as appropriate.