2

I have a info.properties file where I have this MY_NAME property and I can use this property on my Makefile. I already tried but I can't use that property directly on myScript.sh file.

So I'm trying to pass that property as argument to myScript.sh. And I'm doing like this:

On Makefile:

my_stage:
    chmod 777 myScript.sh && ./myScript.sh $(MY_NAME)

On myScript.sh I have this:

#!/bin/bash -e
source .build/utils.sh

MY_NAME=$1
echo "MY_NAME=${MY_NAME}"

But I'm always getting this error:

chmod 777 myScript.sh && ./myScript.sh My-name-Mariana
.build/utils.bash: line 596: My-name-Mariana: command not found
make: *** [test] Error 127

How can I solve this?

UPDATE:

I know .build/utils.bash is tryind to execute my parameter, I can see that on the error. But I can't change that file because I don't have it because is not part of my code project.

2
  • 1
    The error seems to be coming from deep inside a file called .build/utils.bash that you don't mention (is this file itself sourced from .build/utils.sh?) Feb 15, 2020 at 13:13
  • Well, if make is installed which it should be, you can try removing the -e and see where it takes you.
    – Jetchisel
    Feb 15, 2020 at 13:31

2 Answers 2

3

On line 596 (or so) of your .build/utils.bash script you are trying to call My-name-Mariana as a command. Either as a literal or as $1. It doesn't exist so the execution fails immediately (due to the -e flag on bash).

.build/utils.bash: line 596: My-name-Mariana: command not found

The solution is to fix the code. You've not provided it here so we can't offer an specific suggestion, but I'm sure someone would be happy to do so if you updated your question with the relevant context.

2
  • I made an update to my question. I don't have .build/utils.bash. And I already know that file is trying to execute my parameter. But how can I over come that?
    – Ninita
    Feb 15, 2020 at 18:44
  • 1
    @Ninita who wrote myScript.sh, or where did it come from?
    – roaima
    Feb 15, 2020 at 20:49
0

Since your script can source .build/utils.bash, you have already proved that you in fact can read it. For example, try less .build/utils.bash in the directory that contains the Makefile.

To fix the actual problem without modifying .build/utils.bash, you might try assigning the contents of $1 into your MY_NAME variable and then using the shift command to remove it from $1 - before you source .build/utils.sh.

But then utils.bash receives $1 as an empty string, which may cause it to fail or to do something different - without reading utils.bash or some documentation about it, it will be impossible to know what it expects.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .