I have a simple shell script:

echo test

I can execute script successfully as:



source ./test.sh

However, the following throws an error:

. ./test.sh


.: Command not found.

What could be causing the error? This works on el capitan but not on sierra.

I'm running macOS 10.12.3 with the default terminal.


EDIT: I've rewritten the question in order to simplify it with a small test script rather than my actual production script - this shows that the issue is the execution environment rather than the script.

  • Your script makes no sense. Is that something you are writing or did you copy that from somewhere? – Allan Feb 16 '17 at 18:13
  • That's just part of the script - it's forcing me to use . ./ and not ./ - the script then goes on to do some EXPORT and sets various ant parameters. This script has been in use for many years - I've never had a problem with it until trying to execute it on sierra. – csilk Feb 16 '17 at 18:14
  • There's something critical missing because the 2nd line (starts with "echo") will generate an error as written on any *nix system from Linux to Sierra. That said, I have never run across a command that gets executed with a leading period and a space. – Allan Feb 16 '17 at 18:19
  • I don't want to post the full script as it's proprietary, the specifics of the echo command is not relevant, probably just a copy and paste error - my point is that the script does a chmod -x on itself if you run it as ./script.sh and then tells the user to execute it as . ./script.sh I've never seen . ./script.sh not work before. – csilk Feb 16 '17 at 18:22
  • 1
    That leading . is the same as source (see ss64.com/bash/source.html). Try calling the script with source ./script.sh and see if it works. It’s likely the script has that restriction because it’s setting values to be used by other commands. If source also fails, what shell are you using? And what terminal app and specific macOS version? – user137369 Feb 16 '17 at 18:28

It turns out that my default shell was set to CSH which does not support:

. ./

I have switched the default shell to bash and this now works. I think the default shell as changed when my company imaged the MacBook or this is now the default with a fresh install of Sierra.

I will accept this as the answer after the 2 days stackexchange waiting period.

  • What shell is Terminal.app set to in its Preferences? – user3439894 Feb 17 '17 at 4:41
  • echo $SHELL gave the output /bin/csh I have changed it to /bin/bash – csilk Feb 17 '17 at 6:19
  • The default shell used by OS X/macOS as normally shipped from Apple is bash. If Terminal was set to csh, it was not using its default shell and had to have been modified by someone other then Apple. If you didn't do it, then from what you've said it was the company you work for. – user3439894 Feb 17 '17 at 12:03

You must log in to answer this question.

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