From 92a66822165a8f46b15ae19c8beac99990260df4 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:10:10 -0800 Subject: [PATCH] Make 1989/fubar/fubar.sh use bash Fixed for ShellCheck as well. The if [ .. ] was changed to if [[ .. ]] and this was done in the C code as well. --- 1989/fubar/fubar.c | 2 +- 1989/fubar/fubar.sh | 6 +++--- thanks-for-help.md | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/1989/fubar/fubar.c b/1989/fubar/fubar.c index 894ad85d7..34ac78bdf 100644 --- a/1989/fubar/fubar.c +++ b/1989/fubar/fubar.c @@ -10,7 +10,7 @@ if(m && q=='T' && o=='T'){m=0;(void)fread(tt,11,1,stdin);(void)printf("T %9d\n", cc ouroboros.c -o x #define zxc ;{/* cat ./ouroboros.c | ./x $1 > x1 -if [ $? -ne 0 ]; then +if [[ $? -ne 0 ]]; then exit fi mv x1 ./ouroboros.c diff --git a/1989/fubar/fubar.sh b/1989/fubar/fubar.sh index abb4b0ae5..816a1147d 100755 --- a/1989/fubar/fubar.sh +++ b/1989/fubar/fubar.sh @@ -1,8 +1,8 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # to run fubar in the 'proper' way # parse args -if [ $# -ne 1 ]; then +if [[ $# -ne 1 ]]; then echo "usage: $0 number" 1>&2 exit 1 fi @@ -15,5 +15,5 @@ r fubar.c w ouroboros.c EOF chmod +x ouroboros.c -./ouroboros.c $1 +./ouroboros.c "$1" #rm -f ouroboros.c x1 x diff --git a/thanks-for-help.md b/thanks-for-help.md index d76d466b4..9d6a7058b 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -758,6 +758,9 @@ not strictly necessary but nonetheless more correct, even if not warned against. `$PATH`) to files referred to in the code. The path problem was also fixed in [fubar.sh](/1989/fubar/fubar.sh). +Cody also 'modernised' the script to use `bash` and fixed for ShellCheck. The +`if [ .. ]` was changed in the C code as well as the script. + ## [1989/jar.1](/1989/jar.1/jar.1.c) ([README.md](/1989/jar.1/README.md]))