Command syntax problems illustrated by 'cat' command

Project:JNode Shell
Category:bug report
Assigned:Stephen Crawley

In a forum topic, gchii pointed that the following command won't work as expected:

    cat foo.txt -u

When I designed the new syntax for "cat", I had intended the above arguments would be rejected. It turns out that they satisfy the syntax alternative "cat ...", with "-u" and "" matching the FileArgument. It seems that the current syntax implementation cannot express what I'm trying to express here.


Attached is a patch that goes some way to addressing the problem. This patch adds a couple of new Argument flag values that allow you to specify that a Arguement must match something that does or does not "exist". This behavior is implemented for FileArgument, and the specified for key arguments of 'cp', 'cat', 'del', 'mkdir' and some other commands.

Please try this patch out and let me know if you think it improves the behavior of these commands.

(I haven't yet tried to make FileArgument completion aware of these new flags, or implement the flags for other Argument types. Indeed, the existing / nonexistent distinction will make no sense for many Argument types, and they will naturally continue to ignore it.)

patch.txt13.18 KB


Title:Command syntax problems illustrated 'cat' command» Command syntax problems illustrated by 'cat' command


I've read the patch and it looks OK to me, including the fixed hexadecimal values of the flags.


The patch has been committed. I'm leaving this issue open as there is more to be done.