diff --git a/bin/exercise_test.ps1 b/bin/exercise_test.ps1 new file mode 100644 index 00000000..7a2bb33b --- /dev/null +++ b/bin/exercise_test.ps1 @@ -0,0 +1,19 @@ +$slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" + +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath + Write-Output "Cobolcheck not found. Trying to fetch it." + & "${fetchCobolcheckPath}" +} + +Write-Output "Run cobolcheck." +Set-Location $PSScriptRoot + +Invoke-Expression "$cobolcheck -p $slug" +Invoke-Expression "cobc -xj test.cob" + +if ($Lastexitcode -ne 0) { + exit $Lastexitcode +} diff --git a/bin/exercise_test.sh b/bin/exercise_test.sh new file mode 100755 index 00000000..7b4a9da0 --- /dev/null +++ b/bin/exercise_test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ +SLUG=${1:-$(basename "${SCRIPT_DIR}")} +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" + +if [ ! -f "${COBOLCHECK}" ]; then + echo "Cobolcheck not found, try to fetch it." + cd $SCRIPT_DIR/bin/ + bash fetch-cobolcheck +fi +cd $SCRIPT_DIR +$COBOLCHECK -p $SLUG + +# compile and run +echo "COMPILE AND RUN TEST" +cobc -xj test.cob diff --git a/bin/fetch-cobolcheck b/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/bin/fetch-cobolcheck +++ b/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/bin/fetch-cobolcheck.ps1 b/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/bin/fetch-cobolcheck.ps1 +++ b/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/bin/sync-fetch-cobolcheck-files b/bin/sync-exercise-files similarity index 68% rename from bin/sync-fetch-cobolcheck-files rename to bin/sync-exercise-files index 6400e009..64b9b571 100755 --- a/bin/sync-fetch-cobolcheck-files +++ b/bin/sync-exercise-files @@ -7,4 +7,6 @@ for test_dir in exercises/{concept,practice}/*; do for file in fetch-cobolcheck fetch-cobolcheck.ps1; do cp "bin/${file}" "${test_dir}/bin/${file}" done + cp "bin/exercise_test.sh" "${test_dir}/test.sh" + cp "bin/exercise_test.ps1" "${test_dir}/test.ps1" done diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck b/exercises/practice/acronym/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/acronym/bin/fetch-cobolcheck +++ b/exercises/practice/acronym/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/acronym/test.ps1 b/exercises/practice/acronym/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/acronym/test.ps1 +++ b/exercises/practice/acronym/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/acronym/test.sh b/exercises/practice/acronym/test.sh old mode 100644 new mode 100755 index ed4a27a1..7b4a9da0 --- a/exercises/practice/acronym/test.sh +++ b/exercises/practice/acronym/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck b/exercises/practice/all-your-base/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/all-your-base/test.ps1 b/exercises/practice/all-your-base/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/all-your-base/test.ps1 +++ b/exercises/practice/all-your-base/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/all-your-base/test.sh b/exercises/practice/all-your-base/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/all-your-base/test.sh +++ b/exercises/practice/all-your-base/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck b/exercises/practice/allergies/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/allergies/bin/fetch-cobolcheck +++ b/exercises/practice/allergies/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/allergies/test.ps1 b/exercises/practice/allergies/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/allergies/test.ps1 +++ b/exercises/practice/allergies/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/allergies/test.sh b/exercises/practice/allergies/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/allergies/test.sh +++ b/exercises/practice/allergies/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck b/exercises/practice/anagram/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/anagram/bin/fetch-cobolcheck +++ b/exercises/practice/anagram/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/anagram/test.ps1 b/exercises/practice/anagram/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/anagram/test.ps1 +++ b/exercises/practice/anagram/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/anagram/test.sh b/exercises/practice/anagram/test.sh old mode 100644 new mode 100755 index ed4a27a1..7b4a9da0 --- a/exercises/practice/anagram/test.sh +++ b/exercises/practice/anagram/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/armstrong-numbers/test.ps1 b/exercises/practice/armstrong-numbers/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/armstrong-numbers/test.ps1 +++ b/exercises/practice/armstrong-numbers/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/armstrong-numbers/test.sh b/exercises/practice/armstrong-numbers/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/armstrong-numbers/test.sh +++ b/exercises/practice/armstrong-numbers/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/atbash-cipher/test.ps1 b/exercises/practice/atbash-cipher/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/atbash-cipher/test.ps1 +++ b/exercises/practice/atbash-cipher/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/atbash-cipher/test.sh b/exercises/practice/atbash-cipher/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/atbash-cipher/test.sh +++ b/exercises/practice/atbash-cipher/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck b/exercises/practice/binary-search/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary-search/test.ps1 b/exercises/practice/binary-search/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/binary-search/test.ps1 +++ b/exercises/practice/binary-search/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/binary-search/test.sh b/exercises/practice/binary-search/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/binary-search/test.sh +++ b/exercises/practice/binary-search/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/binary/bin/fetch-cobolcheck b/exercises/practice/binary/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/binary/bin/fetch-cobolcheck +++ b/exercises/practice/binary/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary/test.ps1 b/exercises/practice/binary/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/binary/test.ps1 +++ b/exercises/practice/binary/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/binary/test.sh b/exercises/practice/binary/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/binary/test.sh +++ b/exercises/practice/binary/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/bob/bin/fetch-cobolcheck b/exercises/practice/bob/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/bob/bin/fetch-cobolcheck +++ b/exercises/practice/bob/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/bob/test.ps1 b/exercises/practice/bob/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/bob/test.ps1 +++ b/exercises/practice/bob/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/bob/test.sh b/exercises/practice/bob/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/bob/test.sh +++ b/exercises/practice/bob/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck b/exercises/practice/circular-buffer/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/circular-buffer/test.ps1 b/exercises/practice/circular-buffer/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/circular-buffer/test.ps1 +++ b/exercises/practice/circular-buffer/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/circular-buffer/test.sh b/exercises/practice/circular-buffer/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/circular-buffer/test.sh +++ b/exercises/practice/circular-buffer/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/collatz-conjecture/test.ps1 b/exercises/practice/collatz-conjecture/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/collatz-conjecture/test.ps1 +++ b/exercises/practice/collatz-conjecture/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/collatz-conjecture/test.sh b/exercises/practice/collatz-conjecture/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/collatz-conjecture/test.sh +++ b/exercises/practice/collatz-conjecture/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck b/exercises/practice/complex-numbers/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/complex-numbers/test.ps1 b/exercises/practice/complex-numbers/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/complex-numbers/test.ps1 +++ b/exercises/practice/complex-numbers/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/complex-numbers/test.sh b/exercises/practice/complex-numbers/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/complex-numbers/test.sh +++ b/exercises/practice/complex-numbers/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/darts/bin/fetch-cobolcheck b/exercises/practice/darts/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/darts/bin/fetch-cobolcheck +++ b/exercises/practice/darts/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/darts/test.ps1 b/exercises/practice/darts/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/darts/test.ps1 +++ b/exercises/practice/darts/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/darts/test.sh b/exercises/practice/darts/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/darts/test.sh +++ b/exercises/practice/darts/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck b/exercises/practice/diamond/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/diamond/bin/fetch-cobolcheck +++ b/exercises/practice/diamond/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/diamond/test.ps1 b/exercises/practice/diamond/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/diamond/test.ps1 +++ b/exercises/practice/diamond/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/diamond/test.sh b/exercises/practice/diamond/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/diamond/test.sh +++ b/exercises/practice/diamond/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/difference-of-squares/test.ps1 b/exercises/practice/difference-of-squares/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/difference-of-squares/test.ps1 +++ b/exercises/practice/difference-of-squares/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/difference-of-squares/test.sh b/exercises/practice/difference-of-squares/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/difference-of-squares/test.sh +++ b/exercises/practice/difference-of-squares/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/eliuds-eggs/test.ps1 b/exercises/practice/eliuds-eggs/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/eliuds-eggs/test.ps1 +++ b/exercises/practice/eliuds-eggs/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/eliuds-eggs/test.sh b/exercises/practice/eliuds-eggs/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/eliuds-eggs/test.sh +++ b/exercises/practice/eliuds-eggs/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck b/exercises/practice/grade-school/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/grade-school/test.ps1 b/exercises/practice/grade-school/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/grade-school/test.ps1 +++ b/exercises/practice/grade-school/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/grade-school/test.sh b/exercises/practice/grade-school/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/grade-school/test.sh +++ b/exercises/practice/grade-school/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck b/exercises/practice/hamming/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/hamming/bin/fetch-cobolcheck +++ b/exercises/practice/hamming/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hamming/test.ps1 b/exercises/practice/hamming/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/hamming/test.ps1 +++ b/exercises/practice/hamming/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/hamming/test.sh b/exercises/practice/hamming/test.sh index 8bb4caa3..7b4a9da0 100755 --- a/exercises/practice/hamming/test.sh +++ b/exercises/practice/hamming/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck @@ -18,4 +14,3 @@ $COBOLCHECK -p $SLUG # compile and run echo "COMPILE AND RUN TEST" cobc -xj test.cob - diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck b/exercises/practice/hello-world/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hello-world/test.ps1 b/exercises/practice/hello-world/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/hello-world/test.ps1 +++ b/exercises/practice/hello-world/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/hello-world/test.sh b/exercises/practice/hello-world/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/hello-world/test.sh +++ b/exercises/practice/hello-world/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck b/exercises/practice/high-scores/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/high-scores/test.ps1 b/exercises/practice/high-scores/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/high-scores/test.ps1 +++ b/exercises/practice/high-scores/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/high-scores/test.sh b/exercises/practice/high-scores/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/high-scores/test.sh +++ b/exercises/practice/high-scores/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck b/exercises/practice/isogram/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/isogram/bin/fetch-cobolcheck +++ b/exercises/practice/isogram/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/isogram/test.ps1 b/exercises/practice/isogram/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/isogram/test.ps1 +++ b/exercises/practice/isogram/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/isogram/test.sh b/exercises/practice/isogram/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/isogram/test.sh +++ b/exercises/practice/isogram/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck b/exercises/practice/knapsack/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/knapsack/test.ps1 b/exercises/practice/knapsack/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/knapsack/test.ps1 +++ b/exercises/practice/knapsack/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/knapsack/test.sh b/exercises/practice/knapsack/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/knapsack/test.sh +++ b/exercises/practice/knapsack/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/leap/bin/fetch-cobolcheck b/exercises/practice/leap/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/leap/bin/fetch-cobolcheck +++ b/exercises/practice/leap/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/leap/test.ps1 b/exercises/practice/leap/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/leap/test.ps1 +++ b/exercises/practice/leap/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/leap/test.sh b/exercises/practice/leap/test.sh index 081f6fbc..7b4a9da0 100755 --- a/exercises/practice/leap/test.sh +++ b/exercises/practice/leap/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck @@ -15,6 +11,6 @@ fi cd $SCRIPT_DIR $COBOLCHECK -p $SLUG -# compile and run +# compile and run echo "COMPILE AND RUN TEST" cobc -xj test.cob diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck b/exercises/practice/luhn/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/luhn/bin/fetch-cobolcheck +++ b/exercises/practice/luhn/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/luhn/test.ps1 b/exercises/practice/luhn/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/luhn/test.ps1 +++ b/exercises/practice/luhn/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/luhn/test.sh b/exercises/practice/luhn/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/luhn/test.sh +++ b/exercises/practice/luhn/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck b/exercises/practice/matching-brackets/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/matching-brackets/test.ps1 b/exercises/practice/matching-brackets/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/matching-brackets/test.ps1 +++ b/exercises/practice/matching-brackets/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/matching-brackets/test.sh b/exercises/practice/matching-brackets/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/matching-brackets/test.sh +++ b/exercises/practice/matching-brackets/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck b/exercises/practice/meetup/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/meetup/bin/fetch-cobolcheck +++ b/exercises/practice/meetup/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/meetup/test.ps1 b/exercises/practice/meetup/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/meetup/test.ps1 +++ b/exercises/practice/meetup/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/meetup/test.sh b/exercises/practice/meetup/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/meetup/test.sh +++ b/exercises/practice/meetup/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/nucleotide-count/test.ps1 b/exercises/practice/nucleotide-count/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/nucleotide-count/test.ps1 +++ b/exercises/practice/nucleotide-count/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/nucleotide-count/test.sh b/exercises/practice/nucleotide-count/test.sh index 8bb4caa3..7b4a9da0 100755 --- a/exercises/practice/nucleotide-count/test.sh +++ b/exercises/practice/nucleotide-count/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck @@ -18,4 +14,3 @@ $COBOLCHECK -p $SLUG # compile and run echo "COMPILE AND RUN TEST" cobc -xj test.cob - diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck b/exercises/practice/pangram/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/pangram/bin/fetch-cobolcheck +++ b/exercises/practice/pangram/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pangram/test.ps1 b/exercises/practice/pangram/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/pangram/test.ps1 +++ b/exercises/practice/pangram/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/pangram/test.sh b/exercises/practice/pangram/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/pangram/test.sh +++ b/exercises/practice/pangram/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pascals-triangle/test.ps1 b/exercises/practice/pascals-triangle/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/pascals-triangle/test.ps1 +++ b/exercises/practice/pascals-triangle/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/pascals-triangle/test.sh b/exercises/practice/pascals-triangle/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/pascals-triangle/test.sh +++ b/exercises/practice/pascals-triangle/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck b/exercises/practice/pig-latin/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pig-latin/test.ps1 b/exercises/practice/pig-latin/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/pig-latin/test.ps1 +++ b/exercises/practice/pig-latin/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/pig-latin/test.sh b/exercises/practice/pig-latin/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/pig-latin/test.sh +++ b/exercises/practice/pig-latin/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck b/exercises/practice/protein-translation/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/protein-translation/test.ps1 b/exercises/practice/protein-translation/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/protein-translation/test.ps1 +++ b/exercises/practice/protein-translation/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/protein-translation/test.sh b/exercises/practice/protein-translation/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/protein-translation/test.sh +++ b/exercises/practice/protein-translation/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck b/exercises/practice/queen-attack/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/queen-attack/test.ps1 b/exercises/practice/queen-attack/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/queen-attack/test.ps1 +++ b/exercises/practice/queen-attack/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/queen-attack/test.sh b/exercises/practice/queen-attack/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/queen-attack/test.sh +++ b/exercises/practice/queen-attack/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck b/exercises/practice/raindrops/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/raindrops/test.ps1 b/exercises/practice/raindrops/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/raindrops/test.ps1 +++ b/exercises/practice/raindrops/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/raindrops/test.sh b/exercises/practice/raindrops/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/raindrops/test.sh +++ b/exercises/practice/raindrops/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck b/exercises/practice/reverse-string/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/reverse-string/test.ps1 b/exercises/practice/reverse-string/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/reverse-string/test.ps1 +++ b/exercises/practice/reverse-string/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/reverse-string/test.sh b/exercises/practice/reverse-string/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/reverse-string/test.sh +++ b/exercises/practice/reverse-string/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck b/exercises/practice/rna-transcription/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/rna-transcription/test.ps1 b/exercises/practice/rna-transcription/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/rna-transcription/test.ps1 +++ b/exercises/practice/rna-transcription/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/rna-transcription/test.sh b/exercises/practice/rna-transcription/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/rna-transcription/test.sh +++ b/exercises/practice/rna-transcription/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck b/exercises/practice/robot-simulator/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/robot-simulator/test.ps1 b/exercises/practice/robot-simulator/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/robot-simulator/test.ps1 +++ b/exercises/practice/robot-simulator/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/robot-simulator/test.sh b/exercises/practice/robot-simulator/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/robot-simulator/test.sh +++ b/exercises/practice/robot-simulator/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck b/exercises/practice/roman-numerals/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/roman-numerals/test.ps1 b/exercises/practice/roman-numerals/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/roman-numerals/test.ps1 +++ b/exercises/practice/roman-numerals/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/roman-numerals/test.sh b/exercises/practice/roman-numerals/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/roman-numerals/test.sh +++ b/exercises/practice/roman-numerals/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/rotational-cipher/test.ps1 b/exercises/practice/rotational-cipher/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/rotational-cipher/test.ps1 +++ b/exercises/practice/rotational-cipher/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/rotational-cipher/test.sh b/exercises/practice/rotational-cipher/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/rotational-cipher/test.sh +++ b/exercises/practice/rotational-cipher/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck b/exercises/practice/scrabble-score/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/scrabble-score/test.ps1 b/exercises/practice/scrabble-score/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/scrabble-score/test.ps1 +++ b/exercises/practice/scrabble-score/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/scrabble-score/test.sh b/exercises/practice/scrabble-score/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/scrabble-score/test.sh +++ b/exercises/practice/scrabble-score/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck b/exercises/practice/secret-handshake/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/secret-handshake/test.ps1 b/exercises/practice/secret-handshake/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/secret-handshake/test.ps1 +++ b/exercises/practice/secret-handshake/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/secret-handshake/test.sh b/exercises/practice/secret-handshake/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/secret-handshake/test.sh +++ b/exercises/practice/secret-handshake/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck b/exercises/practice/sieve/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/sieve/bin/fetch-cobolcheck +++ b/exercises/practice/sieve/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/sieve/test.ps1 b/exercises/practice/sieve/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/sieve/test.ps1 +++ b/exercises/practice/sieve/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/sieve/test.sh b/exercises/practice/sieve/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/sieve/test.sh +++ b/exercises/practice/sieve/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck b/exercises/practice/space-age/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/space-age/bin/fetch-cobolcheck +++ b/exercises/practice/space-age/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/space-age/test.ps1 b/exercises/practice/space-age/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/space-age/test.ps1 +++ b/exercises/practice/space-age/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/space-age/test.sh b/exercises/practice/space-age/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/space-age/test.sh +++ b/exercises/practice/space-age/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck b/exercises/practice/square-root/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/square-root/bin/fetch-cobolcheck +++ b/exercises/practice/square-root/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/square-root/test.ps1 b/exercises/practice/square-root/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/square-root/test.ps1 +++ b/exercises/practice/square-root/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/square-root/test.sh b/exercises/practice/square-root/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/square-root/test.sh +++ b/exercises/practice/square-root/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck b/exercises/practice/triangle/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck +++ b/exercises/practice/triangle/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/triangle/test.ps1 b/exercises/practice/triangle/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/triangle/test.ps1 +++ b/exercises/practice/triangle/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/triangle/test.sh b/exercises/practice/triangle/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/triangle/test.sh +++ b/exercises/practice/triangle/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck b/exercises/practice/two-fer/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/two-fer/test.ps1 b/exercises/practice/two-fer/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/two-fer/test.ps1 +++ b/exercises/practice/two-fer/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/two-fer/test.sh b/exercises/practice/two-fer/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/two-fer/test.sh +++ b/exercises/practice/two-fer/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck b/exercises/practice/yacht/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/yacht/bin/fetch-cobolcheck +++ b/exercises/practice/yacht/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - + output_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/yacht/test.ps1 b/exercises/practice/yacht/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/yacht/test.ps1 +++ b/exercises/practice/yacht/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/yacht/test.sh b/exercises/practice/yacht/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/yacht/test.sh +++ b/exercises/practice/yacht/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck