I just started the Bash-Track to deepen my knowledge about Bash-Programming. The exercise Hamming raises a question: For-Loop or cmp?
I used the command cmp as my first solution. Simply because my problem solving thinking was: “I only need the number of different chars”. But then I saw the community sollution most of them used a for-loop.
How is the Bash-Track intended to be used?
For me, tools like cmp are part of the standard Bash-Environment. Like the Standard-Library in other programming languages.
That is an excellent question. And your observation of “tools like cmp are part of the standard … environment” is accurate.
Bash is used to “glue” many things together, not just the Bash environment. And so, if it is definitely a solid solution to use tools like this.
If you want to use the track with the discipline “nothing external” except for the language itself, we have been careful, so far, to let that happen. If there are tools available in the environment to solve the problem, that exploration is just as valid.
Indeed, we start to appreciate the tools that follow the Unix Way, which is “A tool does one thing, and that one thing well.” along with the idea that the output of that tooling is often most helpful when it can be piped, used for another tool in a chain of commands.
I typically encourage people to try to solve the bash exercises using only bash builtins and the bash language so they can learn the bash language. In my mind, the bash track is about learning the bash language, and is not set up as a Linux shell script track. If you interpret it as the latter, you can solve most exercises entirely using other standard environment languages (assuming they are installed on the container), like awk, jq, Python, etc, all of which have their own tracks!
Note, some few exercises do require external tools (Dart uses float values) which do require some external tools. But they are few and far between.