Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The traditional format of Bash's if/then has `if` and `then` on separate lines:

    if command_or_condition
    then
      branch
    fi
I suppose that to many, this looks wasteful and consequently ugly, so one looks for alternatives.

I always inline the `then`, which requires a semicolon:

    if command_or_condition; then
      branch
    fi
If I was forced to use the traditional format, I'd be definitely annoyed :)


I use:

  if command_or_condition
  then branch
       more_branch
  fi
Given the relationship between ; and newline, and the positions of required ;s in if/then/fi, I assumed that was intended.


How swapping a '\n' char for a ';' is less "wasteful" or "ugly"?




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: