From fc8e3ec05279f4976d14b75efade7e928f8cd01a Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Mon, 11 Mar 2024 00:18:38 -0700 Subject: [PATCH] fix shellcheck errors in 2004/hibachi/src/localhost/test/shell/test1.sh --- .../hibachi/src/localhost/test/shell/test1.sh | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/2004/hibachi/src/localhost/test/shell/test1.sh b/2004/hibachi/src/localhost/test/shell/test1.sh index 5011a353d..698787d2f 100755 --- a/2004/hibachi/src/localhost/test/shell/test1.sh +++ b/2004/hibachi/src/localhost/test/shell/test1.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash cat <<'-EOT-' HTTP/1.0 200 OK @@ -29,31 +29,33 @@ Hibachi/1.0 Shell Test 1

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'GET' ]; then +if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi +if [[ $REQUEST_METHOD == 'GET' ]]; then echo "[ OK ] REQUEST_METHOD" else echo "[ BAD ] REQUEST_METHOD" fi -if [ X"$QUERY_STRING" = X'example=GET+REQUEST+WITH+QUERY-STRING&garibaldi=peek-a-boo' ]; then +if [[ -z $QUERY_STRING ]]; then QUERY_STRING=''; fi +if [[ $QUERY_STRING == 'example=GET+REQUEST+WITH+QUERY-STRING&garibaldi=peek-a-boo' ]]; then echo "[ OK ] QUERY_STRING" else echo "[ BAD ] QUERY_STRING" @@ -61,7 +63,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-'