bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug: readonly array that is empty causes error (whereas not empty do


From: James Thomas Moon
Subject: Re: bug: readonly array that is empty causes error (whereas not empty does not)
Date: Wed, 6 Jan 2016 22:54:44 -0800

I attempted to reproduce the error.  The closest error I could reproduce is slightly different than my original email suggests.
The problem I reproduced below is an undefined variable.  To the best of my recollection, the original error was silent whereas this error, posted below, is "unbound variable".  This may lead to a "behaves as expected" resolution.

> can you post your actual script?

    #!/usr/bin/env bash

    set -u

    readonly -a ARGS=("${@}")
    echo 'ARGS is:'
    echo "${ARGS[*]}"

Running without arguments causes the error

    $ ./test.sh a
    ARGS is:
    a

    $ echo $?
    0

    $ ./test.sh
    ARGS is:
    ./test55.sh: line 7: ARGS[*]: unbound variable

    $ echo $?
    1

There does not appear to be errant variables within the bash instance

    $ { export; env; } | grep -Fe ARGS
    # no output

> What version of Bash are you using?

    $ bash --version
    GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)


-James Thomas Moon

reply via email to

[Prev in Thread] Current Thread [Next in Thread]