News for hackers. Stuff that matters.
Re:Why doesn't Bash's `set -e` do what I expected? by trashtester on Friday October 07, 2022 @04:12AM (#33118614)
> The `let ++` example is pretty damning.

Seems kind of logical, the following c code behaves the same way.

  #include <stdio.h>

  int test(void) {
          int i=0;
          return i++;
  }
  
  void main(void) {
          printf("i = %d\n", test());
  }
'let i++' evaluates to / returns 0 before increasing i, just like c would.
Re:Why doesn't Bash's `set -e` do what I expected? by stevebmark on Saturday October 08, 2022 @02:00PM (#33134475)
I don't mean what it returns, I mean that returning non-zero trips up Bash into thinking it's a non-successful error code. The fact that doing math can trip up error detection implies a fundamental design flaw of the system. Which, I mean, we're in Bash, of course it's poorly designed. I didn't know it was quite this bad though.