This is the first post in the “bashing bash” series to highlight problems in bash and convince systems and software engineers to help building a better alternative.
Bash is a very powerful and useful tool, doing a better job than many other shells and programming languages when used for the intended tasks. Still, it’s hard to believe that writing a software decades later can not be done better.
What does the following command do?
cp $src_file $dst_file
One might think it copies the given file to the specified destination. Looking at the code we can say it was the intention. What would actually happen? It can not be known from the line above. Each
$dst_file expand to zero to N arguments so unexpected things that could happen. The correct command would be
cp "$src_file" "$dst_file"
Forgetting the quotes or leaving them out assuming
$dst_file will always contain one bash word, expanding to exactly one argument each is dangerous.
Keeping quoting everything makes code cluttered.
The suggested solution
$var expands to exactly one argument similar to
"$var" in bash. The new syntax
$*var, consistent with similar syntax in other NGS parts, would expand to zero to N arguments.
Please help building a better alternative
Go to https://github.com/ilyash/ngs/ and contribute some code.