2

What's the difference between:

 sh myscript.sh

and

./myscript.sh
1
  • Type readlink -f $(type -p sh) in the shell, I guess this is not really sh. Oct 7, 2012 at 13:22

1 Answer 1

3

#!/bin/sh loads sh from that path. If on Linux then it is likely a symbolic link to bash.

sh tremor_script.sh uses the PATH environment variable to find sh, which might be totally different.

Track down which sh you are using, maybe using which sh, and following any links. Note that Android uses ash or mksh, depending on the Android version.

However, messages like "junk at end of line" might come from files that have been copied from Windows without the \r\n line endings corrected to \n.

4
  • 1
    nailed it. The #!/bin/sh is called a shebang. It's short for Crash(#)-Bang(!). This line tells the system to use whatever file you specify afterwards to be used to execute the file. In this case, /bin/sh. When you type sh tremor_script.sh the system uses whichever sh program is in your current $PATH. Find out what's screwed up there and you'll be set. Oct 8, 2012 at 12:19
  • Yes ok, I think I got the difference. But on my computer, sh command is pointing to /bin/sh too, so it's weird. I don't know where I should look for this odd behaviour...
    – bagage
    Oct 8, 2012 at 17:12
  • OK, what if you type /bin/sh tremor_script.sh ? Second: try /bin/sh -x tremor_script.sh. The -x should give you a trace which might give some clues. Finally, what the heck is floor1ARM.s?
    – cdarke
    Oct 8, 2012 at 19:13
  • well, the -x shows me the same thing by running the script into the terminal or inside another script. I'll keep searching; and floor1ARM.s is one file of the tremor library.
    – bagage
    Oct 10, 2012 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.