bug-bash
[Top][All Lists]
Advanced

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

${var@A} expands to empty string for unset, but declared variables with


From: Emanuele Torre
Subject: ${var@A} expands to empty string for unset, but declared variables with no attributes
Date: Thu, 7 Apr 2022 03:50:19 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout'
-DNON_INTERACTIVE_LOGIN_SHELLS
uname output: Linux t420 5.15.32-1-lts #1 SMP Mon, 28 Mar 2022
08:54:31 +0000 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.1
Patch Level: 16
Release Status: release

Description:
        `${var@A}' only expands to something if either var is set or is
        declared with attributes; it doesn't expand to `declare -- var'
        for variables that are declared but don't have any attribute and
        are unset.
        
        Shouldn't it expand to `declare -- var' and only expand to the
        empty string if the variable is not declared?
        
        emanuele6

Repeat-By:

        bash-5.1$ printf '%s\n' "${hello@A}"
        
        bash-5.1$ declare hello; printf '%s\n' "${hello@A}"
        
        bash-5.1$ x () { local hello; printf '%s\n' "${hello@A}" ;}; x
        
        bash-5.1$ declare -i hello; printf '%s\n' "${hello@A}"
        declare -i hello
        bash-5.1$ x () { local -u hello; printf '%s\n' "${hello@A}" ;}; x
        declare -u hello



reply via email to

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