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 8267561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:34:40+00:00 2026-06-08T05:34:40+00:00

This is a follow up on this question: Can I use GNU make's SHELL

  • 0

This is a follow up on this question: Can I use GNU make's SHELL variable to connect to a remote shell?

I’d like to use two different shells in a single recipe. One shell is on a host machine, and the other is on a target device that doesn’t have make.
The shell on the host machine is used for tracking tests’ success and failure.
The shell on the target device is used for performing the test.
I’ve successfully used $(eval SHELL=) to change from the host shell to the target shell. However, when I add $(eval SHELL=) to the recipe, it seems like the SHELL never changes. I assume that the two eval functions are evaluated before the recipe is run, so the second expansion cancels the first one out.
Is there a way to make these eval functions expand during run time, or otherwise change the SHELL variable twice in a single recipe?

To illustrate what I’m aiming at, it will be something like this:

test: test_dependencies  
    touch $host_files_for_tracking  
    SHELL = target_shell  
    $(program_to_test) $(params) -o result  
    cmp result gold  
    SHELL = host_shell  
    rm $host_files_for_tracking

Thanks.

Note: When I’m talking about SHELL, I’m referring to the make-internal variable that determines which shell make invokes in order to executes recipe steps, not the environment variable.

  • 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-08T05:34:41+00:00Added an answer on June 8, 2026 at 5:34 am

    If you’re not bound to using only a single recipe, you could split the rule as follows:

    .PHONY: test test_dependencies
    
    test : test_target test_host
    test_host : test_target # to enforce the order
    test_target test_host : test_dependencies
    
    shell_orig := $(SHELL)
    

    Target related rules would look like these:

    .PHONY: test_target test_target_touch
    
    test_target: test_target_touch
    test_target_touch: SHELL = $(shell_orig)
        touch $host_files_for_tracking  
    
    test_target: SHELL = target_shell
        $(program_to_test) $(params) -o result  
    

    And host:

    .PHONY: test_host test_host_cmp
    
    test_host: test_host_cmp
    test_host_cmp: SHELL = $(shell_orig)
        cmp result gold  
    
    test_host: SHELL = host_shell
        rm $host_files_for_tracking
    

    In case of using the most recent GNU Make 3.82, shell_orig hack can be avoided by using private modifier for target-specific SHELL variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow up to this question . Since, it I can't use
This is a follow-on question from the one I asked here . Can constraints
This is a follow-up question to the following if you would like to see:
This is like a follow-up question to this one . Basically what I'm doing
You can consider this a follow-up question to How do I install the OpenSSL
This is a follow-up to a question I posted a while back: Can I
First of all, this is a follow-up question to Should I use WCF or
as a follow up to this question, how can the code be changed so
This is a follow up question to that at Can I create a HTML
This is a follow up question . So, Java store's integers in two's-complements and

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.