Page 1 of 1

Shell is not recognizing commands

Posted: Sat Apr 11, 2015 5:33 am
by osdever
All is fine, but the console is not recognizing commands, like that:
> test
>
instead of
> test
Working!
> .
The code is here:

Code: Select all

....
printw("> ",console);
char * cmd;
char c = 0;
int i=0;
do
{
if(inb(0x60)!=c)
{
c = inb(0x60);
if(c == 28)
{
if(cmd == "test")
kprint("working\n");
kprint("\n> ");
}
if(c>0)
{
cmd[i] = scancode[c+1];
terminal_putchar(scancode[c+1]);
}
}
}
i++;
}
while(c!=1); //exit when ESC is pressed
Where's my error?

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 5:40 am
by osdever
P.S. printw is printing text in the window.

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 6:00 am
by iansjack
You can't compare strings using "==". Take some time out to learn C.

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 6:02 am
by osdever
iansjack wrote:You can't compare strings using "==". Take some time out to learn C.
But what i should do?

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 6:08 am
by iansjack
Sorry, this is an OS development forum, not a place for elementary C tutorials.

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 6:25 am
by Roman
catnikita255 wrote:
iansjack wrote:You can't compare strings using "==". Take some time out to learn C.
But what i should do?
You sound like a troll.

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 6:34 am
by glauxosdev
Edit: I have sent him some private messages to let him know how to come across OS development and this forum. If he continues to ask like that you know the rest... Don't worry.

Regards,
glauxosdev

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 2:45 pm
by alexfru
iansjack wrote:You can't compare strings using "==". Take some time out to learn C.
+1. Also, cmd doesn't point to allocated memory.

Re: Shell is not recognizing commands

Posted: Sat Apr 11, 2015 8:59 pm
by KemyLand
You smell like one of those Java guys who love Java-island coffee :mrgreen: . If you had wrote your kernel in C++, you could have used classes, overloaded operators, etc etc, to create a automatic String class, just like std::string, although I have always looked away from the C model (do it all yourself and do it
with explicit code, and remember not to drink Java-coffee) and the C++ (at least standard) model (dynamic memory is infinite, let's waste it with a constant and fixed "Hello, World!" string!)