I want to automate some deployment steps.
Have CD server, it runs on Linux (in bash). Project is then configured to run bash script on actual app server to perform deployment. SSH is used to connect from CD runner to actual server.
Whole setup relies on an assumption that failing deployment is signaled by appropriate non zero exit code.
Want to add extra safety, so that syntax errors stop/fail deployment early. However, Bash by default do not adhere to convention of exit codes for syntax errors in script. O_O
Unfortunately "/bin/sh -n ..." will NOT return non-zero on syntax error.
Second technique tried, " $(/bin/sh -n ...) | wc -c | ... ", fails because it can not find the script file. I'm baffled by that error. Its the same file/the same command as in first technique.
Setup details:
- CD runner running Linux & bash
- app server running Windows & OpenSSH & bash
- since those two are different bash installations, validation have to happen in app server bash - so over SSH
Question:
Did I missed any option/flag/env variable that will instruct Bash to use non-zero exit code for syntax errors?
Or: Why would surrounding working /bin/sh invocation with $() make it fail?