LOCK_FD=200 LOCK_FILE=/tmp/lock-file exec ${LOCK_FD}>${LOCK_FILE}
I get an error
exec: 200 not found
This however works
LOCK_FD=200 LOCK_FILE=/tmp/lock-file eval "exec ${LOCK_FD}>${LOCK_FILE}"
Any idea why?
Methinks that's because redirection is performed before variable expansion. man bash
is not quite clear which is done first:
REDIRECTION Before a command is executed, its input and output may be redirected . . .
EXPANSION Expansion is performed on the command line after it has been split into words.
With the redirection done and removed, exec
tries to execute 200
which doesn't exist, and thus the error msg.