Reputation: 389
I would like to do like this
( flock --nonblock ${descr} || exit
...
) ${descr}>/tmp/smth.lock
but I got errors:
syntax error near unexpected token `${descr}'
`) ${descr}>/tmp/smth.lock'
So is it possible to use variable for descriptor? Could anybody help? Thank you!
Upvotes: 2
Views: 777
Reputation: 531848
The syntax is {descr}>/tmp/smth.lock
(no dollar sign) to allocate the file descriptor and assign it to the variable descr
. After this, you could use descr
as a normal variable.
Upvotes: 3