diff --git a/2004/hibachi/src/localhost/test/shell/test2.sh b/2004/hibachi/src/localhost/test/shell/test2.sh index c20ef7ea1..7ec83e5b3 100755 --- a/2004/hibachi/src/localhost/test/shell/test2.sh +++ b/2004/hibachi/src/localhost/test/shell/test2.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash cat <<'-EOT-' HTTP/1.0 200 OK @@ -27,38 +27,40 @@ Hibachi/1.0 Shell Test 2

Assertions

-EOT- -if [ X"$PATH" = X'/usr/local/bin:/usr/bin:/bin' ]; then +if [[ "$PATH" = '/usr/local/bin:/usr/bin:/bin' ]]; then echo "[ OK ] PATH" else echo "[ BAD ] PATH" fi -if [ X"$ENV" = X ]; then +if [[ -z "$ENV" ]]; then echo "[ OK ] ENV" else echo "[ BAD ] ENV" fi -if [ X"$CDPATH" = X ]; then +if [[ -z "$CDPATH" ]]; then echo "[ OK ] CDPATH" else echo "[ BAD ] CDPATH" fi -if [ X"$REQUEST_METHOD" = X'POST' ]; then +if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi +if [[ "$REQUEST_METHOD" = 'POST' ]]; then echo "[ OK ] REQUEST_METHOD" else echo "[ BAD ] REQUEST_METHOD" fi -if [ X"$QUERY_STRING" = X ]; then +if [[ -z "$QUERY_STRING" ]]; then echo "[ OK ] QUERY_STRING" else echo "[ BAD ] QUERY_STRING" fi -if [ X"$HTTP_COOKIE" = X'cookie1=test1.sh; cookie2=test1.sh' -o X"$HTTP_COOKIE" = X'cookie2=test1.sh; cookie1=test1.sh' ]; then +if [[ -z $HTTP_COOKIE ]]; then HTTP_COOKIE=''; fi +if [[ "$HTTP_COOKIE" == 'cookie1=test1.sh; cookie2=test1.sh' || "$HTTP_COOKIE" == 'cookie2=test1.sh; cookie1=test1.sh' ]]; then echo "[ OK ] HTTP_COOKIE" else echo "[ BAD ] HTTP_COOKIE" @@ -66,7 +68,13 @@ fi echo "" -. "$DOCUMENT_ROOT/test/shell/dump.sh" +if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi +# We want to source the file, but for SC1091 the file is not available at the time of this edit. +# +# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x). +# https://www.shellcheck.net/wiki/SC1091 +# shellcheck disable=SC1091 +source "$DOCUMENT_ROOT/test/shell/dump.sh" cat <<'-EOT-'