Shell is not recognizing commands

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Shell is not recognizing commands

Post 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?
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Shell is not recognizing commands

Post by osdever »

P.S. printw is printing text in the window.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Shell is not recognizing commands

Post by iansjack »

You can't compare strings using "==". Take some time out to learn C.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Shell is not recognizing commands

Post by osdever »

iansjack wrote:You can't compare strings using "==". Take some time out to learn C.
But what i should do?
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Shell is not recognizing commands

Post by iansjack »

Sorry, this is an OS development forum, not a place for elementary C tutorials.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Shell is not recognizing commands

Post 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.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
glauxosdev
Member
Member
Posts: 119
Joined: Tue Jan 20, 2015 9:01 am
Libera.chat IRC: glauxosdever

Re: Shell is not recognizing commands

Post 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
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Shell is not recognizing commands

Post 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.
User avatar
KemyLand
Member
Member
Posts: 213
Joined: Mon Jun 16, 2014 5:33 pm
Location: Costa Rica

Re: Shell is not recognizing commands

Post 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!)
Happy New Code!
Hello World in Brainfuck :D:

Code: Select all

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
[/size]
Post Reply