Difference between revisions of "Shell escape"

From NetHackWiki
Jump to navigation Jump to search
(In four paragraphs, describe the shell escape, including how it does upon Unix.)
 
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
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]].
+
In game, the {{kbd|!}} 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 server]]s or other environments in which the player should not reach a shell will disable it.
 
It only works if the person who compiled the game had SHELL defined in [[config.h]]. Persons who build the game for [[public server]]s or other environments in which the player should not reach a shell will disable it.
Line 5: Line 5:
 
In the [[source code]], the <tt>dosh</tt> function handles this. The code for this function, if any, is somewhere under the <tt>nethack-3.4.3/sys</tt> directory for your operating system.
 
In the [[source code]], the <tt>dosh</tt> function handles this. The code for this function, if any, is somewhere under the <tt>nethack-3.4.3/sys</tt> directory for your operating system.
  
The file <tt>nethack-3.4.3/sys/unix/unixunix.c</tt> contains the source for [[Unix]]. If there is a <tt>SHELL</tt> environment variable, then NetHack will start that program, else NetHack will attempt to run <tt>/bin/sh</tt>. In most shells, the <tt>exit</tt> command will then return you to NetHack. Since most Unix now have job control, you could just press Control-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.
+
The file <tt>nethack-3.4.3/sys/unix/unixunix.c</tt> contains the source for shell-escaping for a [[Unix]] system. If there is a <tt>SHELL</tt> environment variable, then NetHack will start that program, else NetHack will attempt to run <tt>/bin/sh</tt>. In most shells, the <tt>exit</tt> command will then return you to NetHack. Since most Unix now have job control, you could just press {{kbd|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.
 
 
 
[[Category:Commands]]
 
[[Category:Commands]]
 +
{{nethack-343}}

Latest revision as of 09:39, 21 December 2015

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 the current version of NetHack.

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 the current version's tag or {{noversion}} as appropriate.