拿这个脚本
#!/bin/sh fd () { echo Hello world exit } trap fd EXIT INT for g in {1..5} do echo foo sleep 1 done