-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added fortune command #24
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// What variable is arrayNum
? You have not declared it in this file.
The fortune command is a fortune cookie, it picks random silly quotes