Skip to main content
added 7 characters in body
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226

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"

Use perl:

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

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

perl -e '$a=shift; `<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"

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"
added 45 characters in body
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226

Use perl:

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

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

perl -e '$a=shift; `<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"

Use perl:

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

Edit This works in csh, too:

perl -e '$a=shift; `<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"

Use perl:

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

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

perl -e '$a=shift; `<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"
added 13 characters in body
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226

Use perl:

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

Edit This works in csh, too:

perl -e '$a=shift; `pwd`;`<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"

Use perl:

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

Edit This works in csh, too:

perl -e '$a=shift; `pwd`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"

Use perl:

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

Edit This works in csh, too:

perl -e '$a=shift; `<< other code >>`; $a=~s/h// and exit $a; exit shift' "$?h" "$status"
fixed csh failure
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226
Loading
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226
Loading