[Bug 269663] bmake: Interrupted phony target removes a file

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 18 Feb 2023 16:11:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663

            Bug ID: 269663
           Summary: bmake: Interrupted phony target removes a file
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: 0mp@FreeBSD.org

I have a target that is marked as phony. I also have a file with the same name
as that phony target in my directory. When I interrupt the target, it removes
the file. Here's the repro script:

    set -eu

    # Try to detect bmake.
    make="$(which bmake || which make)"

    rm -rf work
    mkdir work
    cd work

    # Create a file with the same name as the make target we are about to run.
    touch aaa

    # Mark target aaa as phony.
    {
        printf '%s\n'   ".PHONY: aaa"
        printf '%s\n'   "aaa:"
        printf '\t%s\n' "sleep 10"
    } > Makefile

    # Time out before the aaa target completes.
    #
    # NB: The return code of the timeout command is not 0,
    # so temporarily turn of set -e.
    set +e
    timeout 2s make aaa
    set -e

    # Verify that the aaa file is still there.
    if [ -f aaa ]; then
            echo OK
            exit 0
    else
            echo FAIL
            exit 1
    fi


I've tested that on FreeBSD 13.1-RELEASE amd64.

Interestingly, I cannot reproduce it on macOS with bmake 20230208.

-- 
You are receiving this mail because:
You are the assignee for the bug.