Skip to content

[BUG] variable assignment is ignored inside if-chain #1112

@Tirito6626

Description

@Tirito6626

variable assignment/modification is ignored inside if-chain and is replaced with true (aka :) command, only if it isn't the last condition:

if {
                arg == "-V" or arg == "--version": show_version()
                arg == "-h" or arg == "--help": show_help()
                arg == "-v" or arg == "--verbose": VERBOSE = true
                arg == "-j" or arg == "--json": USE_JSON = true
                arg == "--suppress-warnings": SHOW_WARNING = false
                else {
                    error("Invalid argument: {arg}")?
                } 
            }

result:

if [ "$(( $([ "_${arg_41}" != "_-V" ]; echo $?) || $([ "_${arg_41}" != "_--version" ]; echo $?) ))" != 0 ]; then
            show_version__37_v0 
        elif [ "$(( $([ "_${arg_41}" != "_-h" ]; echo $?) || $([ "_${arg_41}" != "_--help" ]; echo $?) ))" != 0 ]; then
            show_help__38_v0 
        elif [ "$(( $([ "_${arg_41}" != "_-v" ]; echo $?) || $([ "_${arg_41}" != "_--verbose" ]; echo $?) ))" != 0 ]; then
            :
        elif [ "$(( $([ "_${arg_41}" != "_-j" ]; echo $?) || $([ "_${arg_41}" != "_--json" ]; echo $?) ))" != 0 ]; then
            :
        elif [ "$([ "_${arg_41}" != "_--suppress-warnings" ]; echo $?)" != 0 ]; then
            __SHOW_WARNING_20=0
        else
            error__42_v0 "Invalid argument: ${arg_41}"
            __status=$?
            if [ "${__status}" != 0 ]; then
                exit "${__status}"
            fi
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions