Is there an existing issue for 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.
Is there an existing issue for this?
Describe the enhancement
As mentioned by @TheEndCrystal28 in Discord:
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
topdirandworkdirare different directories (see below):If you find
topdir/prog.cmissing, AND you findworkdir/prog.cexists, then assume the user has mixed up the args on the command line.If you find
topdir/remarks.mdmissing, AND you findworkdir/remarks.mdexists, 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.cAND noworkdir/prog.care 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.mdAND noworkdir/remarks.mdare 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
topdirandworkdirare different directories (i.e., usestat(2)and check if thedev_tandino_tvalues are different).If
topdirandworkdirare the same directories, then treat this as a "invalid command line". Issue an error message tostderr, print the usage message, and exit 3.This check should be done before the
prog.candremarks.mdchecks.UPDATE 3b
This check could be extended apply to checking
Makefileas well.An "invalid command line" error would also arise if you found
workdir/Makefileand NOTtopdir/Makefile.It is OK if
Makefileis found in BOTHtopdirandworkdir(after determining thattopdirandworkdirare different directories). The submitter might have a reason to use aworkdir/Makefile.If no
topdir/MakefileAND if noworkdir/Makefileare found, don't trigger an "invalid command line" error. Let the content checking code later on deal with that as it does now.