Posts Tagged ‘sh’

Syntax error: Bad fd number

Tuesday, September 23rd, 2008

I just noticed that (part) of my Makefile could not be executed on my own machine. It gives me a

 /bin/sh: Syntax error: Bad fd number

error. On the target machine this runs fine. My own machine runs Ubuntu but the target machine another linux (RHEL). So what is the difference?

The suspicious line contains a output redirect:

command >&/dev/null

This will run corrent in csh or bash (bash is compatible in this case with csh). But Ubuntu links /bin/sh to dash! You might never heard of dash – me neither.
So I changed the output redirect into something more compatible to solve this problem:

command >/dev/null 2>&1