Bash Argument Parsing and Quoting (2016)
jefftk.com
jefftk.com
It also explains PHP, because PHP was tightly integrated with Apache via shared library, and in the 90's, lots of hosting providers were spinning up LAMP.
So basically if you wanted to buy hosting in the 90's, you could pay $20/month for shared PHP, or $200/month for a dedicated box running Perl.
PHP creator Rasmus had a good talk about that recently. So shared hosting was essentially "remote OS" that was cheap.
-----
Exceptions to the rule: Python and Ruby. People installed them because they were nicer languages, and mainly used them on the server side. But Python even made it to the client side in many instances because people like the language! (Dropbox, IPython/Jupyter, etc.)
bash was the default on Linux, which was huge. Other Unixes like Solaris and BSDs used other shells, but yeah it does seem true that bash was helped along by Linux.
I think Linus said that bash was literally the first program that ever ran on Linux, which made sense. Before that I guess bash was run on Solaris and commercial Unixes, and wasn't that popular.
This is not a correct way to do shell quoting.
The code doesn't quite follow this description, but it's not correct either:
$ tmp=$(printf '\nX')
$ newline=${tmp%X}
$ printf '['; quote "$newline"; printf ']\n'
[
]
$ quote 'foo+\bar'
'foo+\\bar'* Add ' at the beginning and end
* Replace internal ' with '\''
This is because inside '-quoted string only ' itself has special semantics.
> wrap each argument in 's if it contains anything suspicious.
Such vague advice is wrong in all contexts.
printf '%q' <string_to_quote>Simple Word Evaluation in Unix Shell
http://www.oilshell.org/release/latest/doc/simple-word-eval....
parsing and evaluation aren't interleaved, and code and data aren't confused
No Implicit Splitting, Dynamic Globbing, or Empty Elision
Opt In to the Old Behavior With Explicit Expressions
Also related: Oil Doesn't Confuse Flags and Files http://www.oilshell.org/blog/2020/02/dashglob.html
string=$(printf ' %q' "${array[@]}") function quote() {
echo "${@@Q}"
}
(In both cases, the generated output is understood bash, but not necessarily by other POSIX-compliant shells.)It has plugins for most IDEs, and just reading the wiki entries for the error messages you encounter will teach you a lot of useful things about bash.