Skip to main content

Questions tagged [declare]

7 votes
1 answer
622 views

I've read what's listed in Bibliography regarding unset, declare, local and "Shell Functions". My version of Bash is GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) var='outer' ...
the_eraser's user avatar
6 votes
1 answer
273 views

Our RHEL8 servers don't have nc available, but at some time in the past someone using this shared account defined an nc function: $ declare -f nc | head -1 nc () $ I am trying to determine where this ...
wytten's user avatar
  • 163
1 vote
1 answer
66 views

Main question: how would one get the delta for declare -F, between that in the current shell, and that as if the shell just started (first two commands below). $(declare -F) does not solve the ...
Erwann's user avatar
  • 729
5 votes
2 answers
764 views

This is specifically about bash's declare - the general case is pretty exhaustively dealt with in this answer (which mentions "the typeset/declare/export -p output of ksh93, mksh, zsh" but ...
muru's user avatar
  • 78.4k
0 votes
1 answer
148 views

I'm attempting to write a function that writes arrays with a name that's passed in. Given the following bash function: function writeToArray { local name="$1" echo "$name" ...
Lee's user avatar
  • 549
1 vote
2 answers
1k views

How do I get the FZF Preview Window to Display Functions from my Current Bash Environment? I want to list my custom bash functions using FZF, and view the code of a selected function in the FZF ...
user2514157's user avatar
3 votes
1 answer
442 views

With bash >5, I'm trying to assign a different value to variables depending on the architecture specified in a variable. I use a function to do so. This works perfectly: # arguments: variable ...
DeadBranch's user avatar
1 vote
1 answer
69 views

I downloaded the CLI Client habash for the habit/routine gameification project habatica.com. In the fandom wiki for habash it is written that, I need to set environment variables. Additonally I want ...
Josomeister's user avatar
1 vote
1 answer
1k views

I learned from the following sources: curl -O: Download a file with curl on Linux / Unix command line jq: How to urlencode data for curl command? Multiple files and curl -J: download pdf files from ...
Oo'-'s user avatar
  • 255
5 votes
1 answer
712 views

I stumbled by accident on the following bash behaviour, which is for me kind of unexpected. # The following works $ declare bar=Hello # Line 1 $ declare -p bar ...
Axel Krypton's user avatar
0 votes
1 answer
1k views

I'm new to bash. I'm trying to write a script that will read data from a text find and declare some variables. In the example below we read from a tab delimited file "ab.txt" that looks like this: ...
Adi Ro's user avatar
  • 101
4 votes
1 answer
2k views

I have this very simple script: #!/bin/bash read local _test echo "_test: $_test" This is the output. $ ./jltest.sh sdfsdfs _test: I want the variable _test to be local only. Is this possible?
mrjayviper's user avatar
  • 2,303
6 votes
2 answers
5k views

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 ...
user avatar
9 votes
1 answer
5k views

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[*...
U. Windl's user avatar
  • 1,777
67 votes
5 answers
81k views

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 ...
user avatar

15 30 50 per page