Up: neeanotes📜
Last edit: <2020-01-23>

tl;dr shell getopts


# the ':' in front means the flag takes an arg
while getopts w:reh flag; do
    case $flag in
        w) wid=$OPTARG;;
        r) some_thing;;
        e) print_env;;
        h) usage;;
        *) usage;;
    esac
done

# this shift at the end is to reset the args to the env of getopts parsing
shift $((OPTIND-1))