Skip to main content
5 of 5
added 7 characters in body
Ole Tange
  • 37.5k
  • 34
  • 119
  • 228

Use perl:

perl -e '$a=shift; `<< other code >>`; exit $a' $? # Fails in csh

Edit This works in csh, too (and zsh, tcsh, sh, pdksh, ksh93 - though not fish):

perl -e '$a=shift; `<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"
Ole Tange
  • 37.5k
  • 34
  • 119
  • 228