Added fortune command#24
Added fortune command#24calebrwalk5 wants to merge 6 commits intoGandelXIV:mainfrom calebrwalk5:main
Conversation
kernel/advanced_cmds/fortune.h
Outdated
|
|
||
| void ksh_fortune() { | ||
| const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."}; | ||
| kprintc("\n"); |
There was a problem hiding this comment.
// You are passing a "string" on line 6, 8 and 9 as parameter, but kprintc() only accepts 'char'. If you want to print strings, use kprints(), defined in kernel/io.h.
Added the new $fortune command to ListOfOwnCmds
GandelXIV
left a comment
There was a problem hiding this comment.
Use display.kprintc() to print chars, and io.kprints to print string.
Also we dont have a random generation library, so no rand() function.
Had to do some tweaks to make it work.
| void ksh_fortune() { | ||
| const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."}; | ||
| kprintc("\n"); | ||
| int RandIndex = rand() % sizeof(fortunes); |
There was a problem hiding this comment.
// We write all libraries from scratch, so no rand() function is available. You will need to write a rand.c and rand.h file in lib/.
GandelXIV
left a comment
There was a problem hiding this comment.
@calebrwalk Should i close this pull request?
| const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."}; | ||
| kprintc('\n'); | ||
| int RandIndex = rand() % sizeof(fortunes); | ||
| kprints(arrayNum[RandIndex]); |
There was a problem hiding this comment.
// What variable is arrayNum? You have not declared it in this file.
The fortune command is a fortune cookie, it picks random silly quotes