I was using a bash script to do some automated testing on a CLI. All of a sudden it does not seem to work. Seems like our devops have done some changes to the OS.
The error i see is
bash-3.2$ sh cli-unit.sh
cli-unit.sh: line 53: syntax error near unexpected token `('
cli-unit.sh: line 53: ` if ! diff < (echo "$EXPECTED") < (echo "$FOUND") > /dev/null; then'
The code part is
runTest() {
local TITLE="$1"
local BODY="$2"
COUNTER=$((COUNTER + 1))
local SHELL=$(getShell "$BODY")
local EXPECTED=$(getOutput "$BODY")
local FOUND=$(eval "$SHELL")
if ! diff <(echo "$EXPECTED") <(echo "$FOUND") > /dev/null; then
echo "--- FAIL: $TITLE"
diff <(echo "$EXPECTED") <(echo "$FOUND")
return 1
fi
PASSED=$((PASSED + 1))
return 0
}
Can someone change/correct this for me ? i am unable to rectify it. Thanks in advance.
#!/bin/sh
to the top of the shell code fragment in ShellCheck. See my answer. – Kusalananda Mar 08 '18 at 07:20