Stack Overflow archive
3 scoreaccepted

Boolean variable becomes command-line option

score
3
question views
228
license
CC BY-SA 3.0

Shorter than the other answers:

bash
OPTION=$($BOOL && echo --option)

Is it better? I'm not sure.

As long as it works and you understand it, I don't see a reason to change it.

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.