mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-21 12:57:58 +02:00
43 lines
1.5 KiB
Plaintext
43 lines
1.5 KiB
Plaintext
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# issues with taking the length of nameref variables
|
|
#
|
|
# just the basics
|
|
|
|
scalar=foo
|
|
declare -a array=(foo)
|
|
|
|
declare -n name=array
|
|
declare -n name1=array[0]
|
|
declare -n name2=unset
|
|
declare -n name3=
|
|
declare -n name4='a&b'
|
|
|
|
echo ${#name} # length of nameref resolving to set variable
|
|
echo ${#name1} # length of nameref resolving to valid non-identifier
|
|
echo ${#name2} # length of nameref resolving to unset variable
|
|
echo ${#name3} # length of nameref resolving to empty string
|
|
echo ${#name4} # length of nameref resolving to invalid non-identifier
|
|
|
|
unset -n name name1
|
|
|
|
declare -n name=scalar
|
|
declare -n name1=scalar[0]
|
|
name4='aa&bb'
|
|
declare -n name4
|
|
|
|
echo ${#name} # length of nameref resolving to set variable
|
|
echo ${#name1} # length of nameref resolving to valid non-identifier
|
|
echo ${#name4} # length of nameref resolving to invalid non-identifier
|