Skip to main content

Questions tagged [indirection]

5 votes
2 answers
442 views

In the shell I can do $ a=b b=c; eval echo \$$a c How do I do the same with GNU Make's $(eval) function? $ cat Makefile a=b b=c x:; echo {What goes here in order to get:} $ make c
Dan Jacobson's user avatar
1 vote
4 answers
168 views

Sorry, that was all too confusing, (my bad) Let me try to explain again, but with a more simple example: #define a new var and export it to the "env": export VAR_ONE=thisIsVarOne # check if ...
Chris V.'s user avatar
0 votes
1 answer
164 views

One challenging thing I've encountered in bash scripting is using variable expansion in a recursive way. However, I was able to figure out [through ChatGPT] that I could use indirect subsitution to ...
thinksinbinary's user avatar
0 votes
2 answers
707 views

#!/bin/bash mat_1=(ServerAB ServerFR ServerPE ServerAM ServerHU) st="mat_1"; indirect_var='${'${st}'[@]}' #(Please, see the "--Desired Ouput Section--" in comments) #----- What ...
dcubaz's user avatar
  • 23
4 votes
4 answers
1k views

Say: variable="Something that it holds" then echo "$variable" will output: Something that it holds But say I also do: var2="variable"; echo "\$$(echo $var2)" ...
Swaroop Joshi's user avatar
1 vote
3 answers
360 views

I am trying to do the following indirect task: host_1=(192.168.0.100 user1 pass1) host_2=(192.168.0.101 user2 pass2) hostlist=( "host_1" "host_2" ) for item in ${hostlist[@]}; do ...
  sxiii's user avatar
4 votes
4 answers
2k views

So I know that you can test for the existence of a regular parameter via indirect expansion by doing something like: foo=1 bar=foo (( ${(P)+bar} )) && print "$bar exists" And I know you can ...
Matt Wilder's user avatar
2 votes
2 answers
456 views

In bash, I understand we can have variable indirect expansion via two ways: Using declare: declare -n foo=bar Using the ${!..} expansion. We can combine both: declare -n foo=SHELL bar=foo echo ${!bar}...
user avatar
2 votes
1 answer
114 views

Consider the following example, it seems it's working fine with the index 0: $ a1=(1 2 3) $ a2=(a b c) $ for x in a1 a2; do echo "${!x}"; done 1 a $ for x in a1 a2; do echo "${!x[0]}"; done 1 a ...
NarūnasK's user avatar
  • 2,555