Search code examples
bashshellopenssl

What do double colons with parameter expansion do?


What does subjectAltName = ${ENV::subjectAltName} in a shell script mean? I've tried this locally on MacOS and it just returns null.

I've gone to various tutorials on bash scripting and I have found that something like

subjectAltName = ${ENV:-subjectAltName}

would mean if ENV is unset or null, the expansion of subjectAltName is substituted. Otherwise, the value of ENV is substituted but I have not seen double colons in the context of parameter expansion. See here for that tutorial. Also here.

I've also seen this usage:

$ENV::HOME/.rnd

Here, I expect a concatenation for whatever these variables are.

This is used for an openssl.conf file.


Solution

  • It's not shell syntax, it's a feature unique to openssl.conf and the OpenSSL CONF library. The config(5) man page says:

    It is also possible to substitute a value from another section using the syntax $section::name or ${section::name}. By using the form $ENV::name environment variables can be substituted.