Zsh Bad Substitution Error When Installing Influxdb2.0

- 1 answer

I am following the installation instructions from this article but I get a bad substitution error from zsh when executing this command:

export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg]${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null

What am I supposed to change for zsh?



${DISTRIB_ID,,} is a Bash-specific parameter expansion to lowercase the value of the variable. suggests ${(L)DISTRIB_ID} as a corresponding operation in Zsh.

But there is no real reason for this to use any constructs specific to either shell; the operation is simple to do portably in POSIX sh too (albeit at the cost of an external process).

For what it's worth, unless there are other reasons you need to, the export statements here are unnecessary, too. See also Correct Bash and shell script variable capitalization

distrib_id=$(lsb_release -si | tr A-Z a-z)
distrib_codename=$(lsb_release -sc)
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg]$distrib_id $distrib_codename stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null