Understanding the Unique Features of zsh Scripting
When you script in zsh
, you can take advantage of certain enhancements that aren’t in bash
. Here’s a quick review of some of those enhancements.
Differences in Variable Expansion
In Chapter 8—Basic Shell Script Construction, I explained the concept of variable expansion, which is also sometimes called parameter expansion. This allows you to write cool scripts that do cool things, such as changing the filename extensions on a whole batch of files at a time. Most of the same variable expansion constructs that are in bash
are also in zsh
, but zsh
has additional ones that provide additional capabilities. Let’s look at a few examples.
Substituting Values
Substituting values in zsh
works the same as it does in bash
, with one exception. That is, if you substitute a value in a text string that includes an exclamation point, you’ll have to escape it in a zsh
script. For example, here’...