caiogondim / bullet-train.zsh

:bullettrain_side: An oh-my-zsh shell theme based on the Powerline Vim plugin
MIT License
2.82k stars 383 forks source link

Interpret the signal name when the return value is grater than 128 #179

Open MedicineYeh opened 7 years ago

MedicineYeh commented 7 years ago

In Linux Bash-scripting ABI, the return value has its specific meaning in different range. Value 128+n means fatal error with signal "n". For more information, please refer to this link: http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF

You can turn on/off this feature by assigning true/false to this variable: BULLETTRAIN_STATUS_EXIT_SIGNAL_SHOW

MedicineYeh commented 7 years ago

Yes, if we consider all cases, it is 4-state status. It is more clear to use one enum instead of two variables to me, since enabling the symbol while disabling the error codes state does not exist. As you mentioned, the state 0 is kinda redundant to the switch STATUS_SHOW=false. Since it's not necessary to make the number to the power of 2, I would consider to either use one of the following:

0) minimal - show only cross on error 1) ret_code - show always return code, do not interpret it 2) ret_code_or_signal - interpret return codes > 128 as signals

or (this is just my habit)

0) minimal - show only cross on error 1) ret_code - show always return code, do not interpret it 2) ret_code_or_signal - interpret return codes > 128 as signals 3) ret_code_or_signal_filtered - interpret return codes > 128 as signals (exclude TSTP siganl)

dawikur commented 7 years ago

Is there a simple way for me to modify this patch? Or I need to fork it, modify and create PR? I do not know if github allows to amend someone else's PR's.

MedicineYeh commented 7 years ago

hum..... good question. I think the easiest way might be I push a new commit with the modifications you want to do. But it's a bit weird that I submit the codes you writes (in blame). Or... take this PR and refactor your codes. This way the history will still show this PR with duplicated condition coding, but it gets fixed in version XXX.

vadviktor commented 7 years ago

@dawikur AFAIK you can just clone @MedicineYeh 's branch and commit to it directly, though in Github, you have to fork his then create a pull request to it, then he can merge that in here. Complicated? Sure is XD

dawikur commented 7 years ago

I will take a look at this, maybe on weekend. I have some working svn segment which I am quite happy about.