Exemplo n.º 1
0
        private static void CheckFunctions()
        {
            // You do not need to call this function, you just need to make
            // sure that it compiles.
            try
            {
                List <string> arr = new List <string>();

                //Builtins
                Builtins.Pwd(arr);
                Builtins.Cd(arr);
                Builtins.Ls(arr);
                Builtins.Echo(arr);
                Builtins.Cat(arr);

                //Globbing
                Globbing.Match("", "");
                Globbing.Star("", "");
                Globbing.Expand("");

                //AliSHe
                AliSHe.GetCommand();
                AliSHe.GetArgs(arr);
                AliSHe.Run();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 2
0
	public static void Run()
	{
		string command = "";
		do
		{
			string current_dir = Builtins.dir_path;
			Console.Write("[aliSHe - {0} $] ", Builtins.JustTheName(current_dir));
			input = Console.ReadLine();
			command = "";
			List<string> inputs = GetCommand();
			List<string> arguments = new List<string>();
			if (inputs.Count != 0)
			{
				command = inputs[0];
				arguments = GetArgs(inputs);
			}
			List<string> args = new List<string>();
			foreach (string pattern in arguments)
			{
				foreach(string matched in Globbing.Expand(pattern))
				{
					args.Add(matched);
				}
			}
			try
			{
				if (command == "ls")
				{
					Builtins.Ls(args);
				}
				else if (command == "cd")
				{
				Builtins.Cd(args);
				}
				else if (command == "echo")
				{
					Builtins.Echo(args);
				}
				else if (command == "pwd")
				{
					Builtins.Pwd(args);
				}
				else if (command == "cat")
				{
					Builtins.Cat(args);
				}
				else if (command != "exit")
				{
					Exec(command, args);
				}
				catch (Exception e)
				{
					Console.WriteLine(e.Message);
				}
			}while (command != "exit");
		}