USF-OS / FogOS

Other
0 stars 48 forks source link

Add test command to user space #52

Open nestrada2 opened 2 months ago

nestrada2 commented 2 months ago

test

The "test" command evaluates a conditional expression. It is an if statement that will return zero (true) or 1 (false), or greater than 1 (error).

Approach

The "test" command will check if any flags were inputted and, based on the expression, will return a truthy or falsy value. For example,test -e myfile.txt will return 0 if that file exists. Will have to use the sys_fstat to obtain information about the specified file.

Files to be Modified/Added

user:

Subcommands Implemented in Test

Command Description
-d file True if file exists and is a directory.
-e file True if file exists (regardless of type).
-f file True if file exists and is a regular file.
file1 -ef file2 True if file1 and file2 exist and refer to the same file.
s1 = s2 True if the strings s1 and s2 are identical.
s1 != s2 True if the strings s1 and s2 are not identical.
n1 -gt n2 True if the integer n1 is algebraically greater than the integer n2.
n1 -lt n2 True if the integer n1 is algebraically less than the integer n2.

Future Development

Add functionality for more flags Add logical operators for combining expressions Edit sh so that test can be incorporated in shell scripting

References

man test

malensek commented 2 months ago

This sounds like a good project, although I don't think there is any reason to modify kernel space. The stat system call should already be enough for getting file system information. When you get a chance, can you specify the exact test features you plan to implement?

nestrada2 commented 2 months ago

Hello Mr. Malensek (@malensek), I updated the project specifications.