Command syntax problems illustrated by 'cat' command

Project:JNode Shell
Component:Code
Category:bug report
Priority:normal
Assigned:Stephen Crawley
Status:active
Description

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

    cat foo.txt -u http://jnode.org

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 "http://jnode.org" matching the FileArgument. It seems that the current syntax implementation cannot express what I'm trying to express here.

#1

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.)

AttachmentSize
patch.txt13.18 KB

#2

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

#3

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

#4

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