All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
2answers
81 views

What is a variable attribute?

I aim to understand the general concept of "variable attributes" hoping it will help me understand what is declare in Bash. What is a variable attribute? Why would someone want to give an attribute ...
7
votes
1answer
208 views

Does `declare -a A` create an empty array `A` in Bash?

Does declare -a A create an empty array A in bash, or does it just set an attribute in case A is assigned to later? Consider this code: set -u declare -a A echo ${#A[*]} echo ${A[*]} A=() echo ${#A[*...
5
votes
3answers
706 views

What is “declare” in Bash?

After reading ilkkachu's answer to this question I learned on the existence of the declare (with argument -n) shell built in. help declare brings: Set variable values and attributes. Declare ...
3
votes
3answers
891 views

Function to conditionally set a variable read-only

If I had a script which sets variables read-only to some odd values, and sets errexit because of other unsafe operations: #!/bin/bash set -e declare -r NOTIFY=$(case "$OS" in (macosx) echo ...
0
votes
2answers
25 views

Parse 3rd entry in declare result

I have this: cd 31 /Users/alexamil/WebstormProjects/oresoftware/botch/botch-shell-overrides.sh the above style output, is given by this command: declare -F my_bash_func How can I grab just the ...