Hacker News new | past | comments | ask | show | jobs | submit login

> For copy-paste: if [[ -n "${TRACE-}" ]]; then set -o xtrace; fi

> People can now enable debug mode, by running your script as TRACE=1 ./script.sh instead of ./script.sh.

The above "if" condition will set xtrace even when user explicitly disables trace by setting TRACE=0.

A correct way of doing this would be:

    if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi

Excellent point. Thanks for this. Fixing it.

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