-w test on OS X gives command not found error

Posted by RobV on Super User See other posts from Super User or by RobV
Published on 2012-04-06T16:14:21Z Indexed on 2012/04/06 17:34 UTC
Read the original article Hit count: 222

Filed under:
|

I'm writing a bash script which I'm testing on OS X though it will ultimately run on a standard Linux environment and running into a weird error.

I have tests like this in my script:

if [ ! -w $BP ]; then
  echo "'$1' not writable"
  exit 1
fi

Which seems pretty sane to me and works fine under Linux but when trying to test on OS X I get the following error message:

startSvr.sh: line 135: [: missing `]' startSvr.sh: line 135: -w: command not found

So is this a case of OS X not supporting the -w test or is there some other reason this isn't working for me? e.g. environment

© Super User or respective owner

Related posts about osx

Related posts about bash