discoteq/flock

Should support -x as a no-op like util-linux does

reesd opened this issue · 7 comments

reesd commented
Should support -x as a no-op like util-linux does

I would gladly consider a PR, or at least some draft documentation (or a unit test) for the feature

ah, per https://github.com/karelzak/util-linux/blob/master/sys-utils/flock.1#L81

how about:

* `-x`, `--exclusive`:
	Obtain an exclusive lock, sometimes called a write lock. Mutually exclusive with the `-s` shared lock option. This is the default.

It looks like this has already been implemented in #8, but hasn't been adequately documented (along with other things added by the patch).

Workaround:

flock_ex()
{
    set +e
    man flock | grep -q "\-x"
    NON_LINUX_FLOCK=$?
    set -e

    if [ "$NON_LINUX_FLOCK" = 1 ]; then
        flock /tmp/docker-up.lock $@
    else
        flock -x /tmp/docker-up.lock -c "$@"
    fi
}

flock_ex docker-compose -p "$PREFIX" -f "$DIR/$RUN_ENV.yml" ps
Mayeu commented

It looks like this has already been implemented in #8, but hasn't been adequately documented (along with other things added by the patch).

The current 0.2.3 version of flock (last one from the tag) does not contains this patch, thus the homebrew version don't work with -x yet.

Would it be possible for you to carve out a new release from the current master?

Mayeu commented

For info, I have added the current master commit of flock in my personal homebrew tap.

I am open to contributing an update to your homebrew tap if a new release is carved out of the current master 🙂

(I can also help making it an addition to the official Homebrew core formula if you wish so).

@Mayeu ok, what do we need to do to release?

  • Is the necessary patch merged?
  • Is it documented?
  • Is it tagged in git?
  • is the homebrew tap updated?

Anything else we'd need to check? Can you confirm you have permissions to make those changes?

Does anyone else want permissions?