diff --git a/ada/ada b/ada/ada index ff80526..b4fdb5a 100755 --- a/ada/ada +++ b/ada/ada @@ -796,23 +796,26 @@ pathtype () { # = something went wrong... no permission? local result encoded_path=$(urlencode "$1") - result=$( - $debug && set -x - curl "${curl_authorization[@]}" \ - -H 'accept: application/json' \ - --silent \ - -X GET "$api/namespace/$encoded_path" - ) - valid=$(echo "$result" | jq 'has("fileType")') - if [[ $valid == 'true' ]] ; then - echo "$result" | jq -r .fileType + command='$debug && set -x + curl "${curl_authorization[@]}" \ + -H "accept: application/json" \ + --silent \ + -X GET "$api/namespace/$encoded_path"' + if $dry_run ; then + echo "$command" else - # Something went wrong. The result should contain an error message in JSON format. - { - echo "Error while getting information about '$path':" - echo "$result" | jq . - } 1>&2 - exit 1 + result=$(eval "$command") + valid=$(echo "$result" | jq 'has("fileType")') + if [[ $valid == 'true' ]] ; then + echo "$result" | jq -r .fileType + else + # Something went wrong. The result should contain an error message in JSON format. + { + echo "Error while getting information about '$path':" + echo "$result" | jq . + } 1>&2 + exit 1 + fi fi } diff --git a/tests/unit_test.sh b/tests/unit_test.sh index 94f45a5..57ca491 100755 --- a/tests/unit_test.sh +++ b/tests/unit_test.sh @@ -13,10 +13,11 @@ test_urlencode() { test_pathtype() { result=`pathtype "/test/a/b/c"` - expected='curl "${curl_authorization[@]}" \ - "${curl_options_no_errors[@]}" \ - -X GET "$api/namespace/$path" \ - | jq -r .fileType' + expected='$debug && set -x + curl "${curl_authorization[@]}" \ + -H "accept: application/json" \ + --silent \ + -X GET "$api/namespace/$encoded_path"' assertEquals \ "the result of pathtype() was wrong" \ "${expected}" "${result}"