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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:29:31+00:00 2026-05-21T10:29:31+00:00

I googled for this, but I can’t figure out why Bash complains with the

  • 0

I googled for this, but I can’t figure out why Bash complains with the following code to check if a directory exists:

test.mk

#!/bin/bash

MYDIR="dl"
all:
        if [ ! -d $MYDIR ]; then
        #if [ ! -d "${MYDIR}" ]; then
        #if [ ! -d ${MYDIR} ]; then
                #Here
        fi

make -f test.mk

if [ ! -d YDIR ]; then
/bin/sh: Syntax error: end of file unexpected
make: *** [all] Error 2

Does someone know why it fails? And why does it call /bin/sh instead of /bin/bash? Thank you.


Edit: unlike Bash, make doesn’t support multi-line block. Here’s working code:

MYDIR="dl"
all:
        if [ ! -d ${MYDIR} ]; then\
                echo "Here";\
        else\
                echo "There";\
        fi
  • 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-05-21T10:29:32+00:00Added an answer on May 21, 2026 at 10:29 am

    The #!/bin/bash shebang that you inserted at top is useless, and it is treated by make as a comment.

    make sends by default commands to /bin/sh. To specify a different shell, use the macro SHELL = /bin/bash.

    Moreover, you need to escape your variable:

    if [ ! -d ${MYDIR} ]
    

    I’m not sure if make can handle multi-line statements, so try to put all the if block in a line.

    if [ ! -d ${MYDIR} ]; then DO_SOMETHING; DO_SOMETHING_ELSE; fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

all. Maybe i've not googled enough, but i can't find any example on this
I've googled this but can't find a satisfactory answer. Which versions of Internet explorer,
I've done a brief search of this site, and googled this, but can't seem
I recently started digging into C# but I can't by my life figure out
I have googled this topic but i can't find any tutorial that i can
I've googled this a lot but i can't find any helpful functions based on
I have searched this site and also googled but can't seem to find the
I have googled this for two days now but I can't get the answer.
I've googled this but can't get a straight answer. I have a mysql database
I've googled this question several times, but I can't find something that works. 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.