This can be a very simple question but I don't understand why it behaves that way. When I invoke
lockfile-create --use-pid --retry 0 /tmp/my_lock_file
it returns 0, and next time it runs it returns some other code(4) as expected since it has already created the lock file. But when I wrap that same code in a bash script file, it always returns 0 as the exit code. Does someone know why it does not work?
Update: Complete bash file content
#! /bin/bash
LOCK=alert
lockfile-create --use-pid --retry 0 $LOCK
LOCK_CREATED=$?
echo "Lock file creation status $LOCK_CREATED"
and this is how I run it ./alert.sh.