This does the same thing and also fixes the trapping in some (possibly broken) shells. Suggested by Michael Kostylev. Signed-off-by: Mans Rullgard <mans@mansr.com>