#!/usr/bin/env bash
function acronym() {
local acronym=""
phrase="${1//[^a-zA-Z\']/ }"
for word in $phrase; do
acronym+="${word:0:1}"
done
echo "${acronym^^}"
}
acronym "$@"
Bash version on my local: GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin21.6.0)
The exact same solution works against all tests when I submit it via the online editor on Exercism portal.
But, all tests fail (empty output against all tests) when submitted via the exercism CLI: exercism submit acronym.sh
Hello. The reason it fails is that the correct filename is acronym.sh but you have submitted a file called acronym-bash.sh via the CLI.
So I suspect that either:
You ran exercism submit acronym-bash.sh
You ran exercism submit acronym* (or similar)
You ran exercism submit and there is a bug
Could you try ensuring that the only file in your directory is acronym.sh and run exercism submit acronym.sh pls? If that works, then we can try and work out which of the above was the root problem. Thanks.
(CC @glennj on the off-chance this is a bash thing and @ErikSchierboom from a CLI perspective)
I think the confusion occurred because running the test suite locally across any file path works as expected. Might be nice to include it as help text.
I don’t understand what that means. What is “any file path”?
If you had locally bothacronym.sh (which passed the tests) and acronym-bash.sh (which failed), then if you submitted onlyacronym-bash.sh, then the remote test runner would fail.
As Glenn said, the filename acronym.sh is hard coded into the test script. See, for instance, this line. run bash acronym.sh 'Portable Network Graphics'. It does not work with other filenames.
Yeah, got it. I had both acronym.sh and acronym-bash.sh as two approaches to the problem and both passed against the tests locally. I missed the hardcoded filename when submitting the solution. Thanks for the support everyone.