Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:17:48+00:00 2026-06-13T10:17:48+00:00

What I want is: Given an array of names, e.g., dependency1, dependency2, .., dependencyN:

  • 0

What I want is:

Given an array of names, e.g., dependency1, dependency2, .., dependencyN:

  1. Append “_DEP_DIR” to each name, to form, e.g., dependency1_DEP_DIR, .., dependencyN_DEP_DIR.
    (XXX_DEP_DIR is predefined as a variable which points to the local disk path of each dependency.)

  2. Invoke a particular batch file(setup.bat) of each dependency.

What I tried is:

DEP_NAMES=dependency1 dependency2 dependency3 dependency4 dependency5 dependency6
DEP_DIRS=$(foreach name,$(DEP_NAMES),$(name)_DEP_DIR)

for dependency in $(DEP_DIRS); do \
    ECHO Copy $$dependency ; \
    ECHO $($$dependency)/installers/windows ; \
    "$($$dependency)/installers/windows/setup.bat" ; \
done

Problem

The first echo can successfully display the appended name, e.g., “dependency1_DEP_DIR“. However, $($$dependency) doesn’t work as expected, “/installers/windows” is printed out, not to say the following call to the batch file.

Toubleshooting

I guess the problem is that the value of my loop counter($$dependency) happens to be the name of a variable that I need to use($(..)). And the form($($$dependency)) is not right(or even not supported?)

Any one got any idea?

Also, if you guys can come up with other ways to meet my requirements which bypass this issue, happy to know that;)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:17:49+00:00Added an answer on June 13, 2026 at 10:17 am

    I see basically two possibilities: either doing everything inside the Makefile, or exporting the needed variables to the shell and expanding them there. The first case relies on foreach (BTW, the definition of DEP_DIRS could be simpler: DEP_DIRS=$(DEP_NAMES:=_DEP_DIR)), with something like

    $(foreach dependency,$(DEP_DIRS),\
          echo "Copy $(dependency)"; \
          echo "dir is $($(dependency))"; \
     )
    

    For the second case, you have to tell make that it must export the relevant variables to the shell (http://www.gnu.org/software/make/manual/html_node/Environment.html):

    export dependency1_DEP_DIR=...
    export dependency2_DEP_DIR=...
    ...
    

    Then you can use a for loop, but obtaining the value of the final variable can be a bit more tricky (indirect expansion is not that easy in strictly POSIX env, see e.g. Lookup shell variables by name, indirectly)

    for dependency in $(DEP_DIRS); do \
      echo "Copy $$dependency"; \
      echo "dir is `eval echo \\$$$$dependency`"; \
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to store some element String.XML's array. Values are given bellow <string-array name=values>
Given an array of ids $galleries = array(1,2,5) I want to have a SQL
I want to mark all maxima along a given axis of an array (which
I have a two-dimensional array and want to sort it by name. I would
I have an array containing names of items. I want to give the user
Given a string, string name = Michael; I want to be able to evaluate
I have an array full of strings with each string being a name. Some
suppose I have an array of names, what I want is that I want
I want the given application (Windows Service) to act as a remoting server as
I want to insert given text to existing pdf at X,Y location provided. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.