Skip to content

Enhancement: consider a sanity check on workdir and topdir before doing make clobber #1378

@lcn2

Description

@lcn2

Is there an existing issue for this?

  • I have searched for existing issues and did not find anything like this

Describe the enhancement

As mentioned by @TheEndCrystal28 in Discord:

There's an annoying feature where if you accidentally swap workdir and topdir in the arguments, the tool runs or in case both workdir/remarks.md and topdir/remarks.md(and fails) before checking that workdir and topdir are in the correct order.

Relevant images, screenshots or other files

No response

Relevant links

https://discord.com/channels/1327029557718417438/1332205820925972541/1476210418065084577

Anything else?

UPDATE 1e

We don't need to go overboard with this sanity check.

Assuming that topdir and workdir are different directories (see below):

If you find topdir/prog.c missing, AND you find workdir/prog.c exists, then assume the user has mixed up the args on the command line.

If you find topdir/remarks.md missing, AND you find workdir/remarks.md exists, then assume the user has mixed up the args on the command line.

Treat these cases as a "invalid command line". Issue an error message to stderr, print the usage message, and exit 3.

If no topdir/prog.c AND no workdir/prog.c are found, don't trigger an "invalid command line" error. Let the content checking code later on deal with that as it does now.

If no topdir/remarks.md AND no workdir/remarks.md are found, don't trigger an "invalid command line" error. Let the content checking code later on deal with that as it does now.

UPDATE 2b

As suggested below, this check will need to determine if topdir and workdir are different directories (i.e., use stat(2) and check if the dev_t and ino_t values are different).

If topdir and workdir are the same directories, then treat this as a "invalid command line". Issue an error message to stderr, print the usage message, and exit 3.

This check should be done before the prog.c and remarks.md checks.

UPDATE 3b

This check could be extended apply to checking Makefile as well.

An "invalid command line" error would also arise if you found workdir/Makefile and NOT topdir/Makefile.

It is OK if Makefile is found in BOTH topdir and workdir (after determining that topdir and workdir are different directories). The submitter might have a reason to use a workdir/Makefile.

If no topdir/Makefile AND if no workdir/Makefile are found, don't trigger an "invalid command line" error. Let the content checking code later on deal with that as it does now.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpost-IOCCC29All work and comments delayed until post-IOCCC29 and post IOCCC judge vacation.top priorityThis a top priory critical path issue for next milestone

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions