From ee0c088b1f2fce64d3cc90b72b48c8f194d6599d Mon Sep 17 00:00:00 2001 From: Casper Date: Mon, 18 Apr 2022 15:28:12 +0200 Subject: [PATCH] setup.sh/setup: show usage when no argument is given (#2540) --- setup.sh | 1 + target/bin/setup | 7 ++++++- test/tests.bats | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 6d8516e9..62dfd3e7 100755 --- a/setup.sh +++ b/setup.sh @@ -236,4 +236,5 @@ function _main return 0 } +[[ -z ${1:-} ]] && set 'help' _main "${@}" diff --git a/target/bin/setup b/target/bin/setup index 2fd8c682..89dbf884 100755 --- a/target/bin/setup +++ b/target/bin/setup @@ -167,4 +167,9 @@ function _main esac } -_main "${@}" +if [[ -z ${1:-} ]] +then + _usage +else + _main "${@}" +fi diff --git a/test/tests.bats b/test/tests.bats index 2f160e2f..38a34e8d 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -936,10 +936,10 @@ EOF # --- setup.sh ---------------------------------- # ----------------------------------------------- -@test "checking setup.sh: exit with error when no arguments provided" { +@test "checking setup.sh: show usage when no arguments provided" { run ./setup.sh - assert_failure - assert_line --index 0 --partial "The command '' is invalid." + assert_success + assert_output --partial "This is the main administration script that you use for all your interactions with" } @test "checking setup.sh: exit with error when wrong arguments provided" {