Bash argument set

Check if a bash argument is set in a script


#!/usr/bin/env bash

if [ -z ${1+x} ]; then
    echo "var is unset";
    echo "var is set to '$1'";
fi will output: var is unset TADA will output: var is set to 'TADA'

Leave a Reply

Your email address will not be published. Required fields are marked *