Covers how to distinguish between an unset variable and a variable explicitly set to an empty string in Bash/POSIX shell scripts. Two approaches are presented: a POSIX-compliant method using parameter expansion (`${var+x}`) that works even with `set -o nounset`, and a Bash 4.2+ built-in check using the `-v` flag. Both

4m read timeFrom nickjanetakis.com
Post cover image
Table of contents
# Parameter Expansion# Bash 4.2+ Built-In Variable Existence# Demo Video

Sort: