The University of Queensland
Menu
  • Home
  • CSSE2310
  • 2012s1
  • Resources
  • Unixhelp
  • Scrpt

trap: Handling command lists

The command list is placed between single quotes, as the command line is scanned twice, once when the shell first encounters the trap command and again when it is being executed.

   trap 'command-list' signal-list

The single quotes inhibit immediate command and variable substitution but are stripped off after the first scan, so that the commands are processed when the command is actually executed.

If command-list is not specified, then the action taken on receipt of any signal in the signal-list is reset to the default system action.

If command-list is an explicitly quoted null command (' ' or " "), then the signals in signal-list are ignored by the shell.

The command-list is treated like a subroutine call. The commands in the list are executed when the signal is trapped and control is then returned to the place at which it was interrupted.

  • Examples

[Home] [Search] [Index]

On This Site

  • Scrpt1
  • Scrpt1 1
  • Scrpt1 2
  • Scrpt1 2 2
  • Scrpt1 2 3
  • Scrpt1 2 4
  • Scrpt1a
  • Scrpt2
  • Scrpt2 1
  • Scrpt2 1 2
  • Scrpt2 1 3
  • Scrpt2 1 3 1
  • Scrpt2 10
  • Scrpt2 2
  • Scrpt2 2 1
  • Scrpt2 2 2
  • Scrpt2 2 3
  • Scrpt2 3
  • Scrpt2 4
  • Scrpt2 4 1
  • Scrpt2 4 1 2
  • Scrpt2 4 2
  • Scrpt2 4 2 1
  • Scrpt2 4 3
  • Scrpt2 4 3 1
  • Scrpt2 5
  • Scrpt2 6
  • Scrpt2 6 1
  • Scrpt2 6 1 1
  • Scrpt2 6 2
  • Scrpt2 6 2 1
  • Scrpt2 6 3
  • Scrpt2 6 3 2
  • Scrpt2 6 4
  • Scrpt2 6 4 1
  • Scrpt2 7
  • Scrpt2 7 1
  • Scrpt2 7 2
  • Scrpt2 7 3
  • Scrpt2 7 4
  • Scrpt2 7 5
  • Scrpt2 8
  • Scrpt2 8 1
  • Scrpt2 8 Op
  • Scrpt2 9
  • Scrpt2 9 1
  • Scrpt2 9 2
  • Scrpt2 9 3
  • Scrpt2 X
The University of Queensland, Australia
Brisbane St Lucia, QLD 4072

+61 7 3365 1111

Other Campuses: UQ Ipswich,
UQ Gatton, UQ Herston

Maps and Directions

© 2013 The University of Queensland

A Member of

Universitas 21 Group of 8

Terms of use | Feedback

ABN: 63 942 912 684
CRICOS Provider No: 00025B

Quick Links

  • For Media
  • Emergency Contact

Social Media

  • Facebook
  • Twitter
  • iTunes U
  • YouTube Channel

Explore

  • Giving to UQ
  • Faculties & Divisions
  • UQ Jobs
  • Contact UQ
  • Services & Facilities