Make an echo command?

Topics: Installation, Off Topic, Other, Using Cosmos (Developing your own OS, projects, etc)
May 18, 2013 at 3:15 PM
How can I make an echo command?
This is how I would like it to work:
I type in the following in my os "echo hello world"
Then I press enter. The OS then show: "hello world" on a new line.

Is this possible in some way?
May 18, 2013 at 5:08 PM
Edited May 19, 2013 at 4:44 PM
string[] args = command.Split(' ');
if(args.Length > 1)
{
    if(args[0] == "echo")
    {
         for(int i = 1; i < args.Length; i++) {
                Console.Write(args[i] + " ");
        } 
        Console.WriteLine();
    }
}
That is a really simple example. If I were you I would write a lexer that will convert the command into a list of Tokens. Then you can use "s to seperate strings, and also add | ,<, >, << and >> for piping.
May 19, 2013 at 12:00 PM
string[] args = command.Split(new char[] {' '}, 2);
switch(args[0])
{
case "echo":
    if(args.Length == 2) Console.WriteLine(arg[1]);
}
May 19, 2013 at 4:24 PM
Edited May 19, 2013 at 4:33 PM
That will only allow for commands with one argument. Not a good example.
May 19, 2013 at 4:35 PM
Grunt: Just a correction in case RackAnd doesn't notice the error:
string args = command.Split(' ');
should be
string[] args = command.Split(' ');
May 19, 2013 at 4:43 PM
Edited May 19, 2013 at 4:43 PM
Stupid typos... xD Thats what I ment