I likely have syntax errors in the following (POSIX) shell snippet:
#!/bin/sh
if tput setaf >/dev/null 2>&1; then tput_init_linux else tput_init_none;
elif tput AF >/dev/null 2>&1; then tput_init_bsd else tput_init_none;
else tput_init_none; fi
ShellCheck 0.10.0 does say nothing about it, I found it basically by accident.
I tested as follows:
if tput setaf >/dev/null 2>&1; then tput_init_linux else tput_init_none; fithis went ok:
tput_init_linux: command not foundReverting the logic with
!:if ! tput setaf >/dev/null 2>&1; then tput_init_linux else tput_init_none; fisays nothing, but if I add one semicolon:
if ! tput setaf >/dev/null 2>&1; then tput_init_linux; else tput_init_none; fiit appears to work as expected:
tput_init_none: command not found
But I seem to be unable to chain these multiple if-statements afterward.
So as you can see, I reached a state, where one statement works, but chaining it seems problematic. Can anyone help?