![]() |
Simple Shell Program - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C) +--- Thread: Simple Shell Program (/Thread-Simple-Shell-Program) Pages:
1
2
|
Simple Shell Program - insidious - 10-16-2016 Shell Program I made for the hell of it. Can't combine arguments (combining arguments, has to be command arg1 arg2 not command arg1arg2 No globbing No Autocomplete Uses the deprecated getlogin because I was too lazy to figure out how to do it the new way but if you're into OS and want some source on the basics of how shells work/syscalls/forking then here you go: Spoiler: P.S I know my naming conventions are complete shit right now but i'm refactoring that tomorrow RE: Simple Shell Program - phyrrus9 - 10-16-2016 I commend you for not just using simple string concatenation and system(), however you should pay close attention to file handles to get a true shell. Oh, and STOP PUTTING THE FUCKING BRACES ON THE SAME FUCKING LINE ITS GIVING ME PTSD ATTACKS! RE: Simple Shell Program - Inori - 10-17-2016 I don't have too much time right now, but I'll definitely try to break it later ![]() (10-16-2016, 07:42 AM)phyrrus9 Wrote: Oh, and STOP PUTTING THE FUCKING BRACES ON THE SAME FUCKING LINE ITS GIVING ME PTSD ATTACKS! I hate VS because it does that automatically and won't fucking stay disabled. RE: Simple Shell Program - phyrrus9 - 10-18-2016 (10-17-2016, 11:58 PM)Ao- Wrote: I don't have too much time right now, but I'll definitely try to break it later VS for me forces it the proper way: Code: void somefunc() RE: Simple Shell Program - Inori - 10-18-2016 (10-18-2016, 12:24 AM)phyrrus9 Wrote:(10-17-2016, 11:58 PM)Ao- Wrote: I don't have too much time right now, but I'll definitely try to break it later Oh, god... Wait. Spaces or tabs? RE: Simple Shell Program - phyrrus9 - 10-18-2016 (10-18-2016, 12:25 AM)Ao- Wrote:(10-18-2016, 12:24 AM)phyrrus9 Wrote:(10-17-2016, 11:58 PM)Ao- Wrote: I don't have too much time right now, but I'll definitely try to break it later Oh...yeah, making tabs be actual tabs (as it should be) is a pain in the ass with VS RE: Simple Shell Program - insidious - 10-18-2016 (10-18-2016, 12:36 AM)phyrrus9 Wrote:(10-18-2016, 12:25 AM)Ao- Wrote:(10-18-2016, 12:24 AM)phyrrus9 Wrote: VS for me forces it the proper way: I use vim, always had tabs --> spaces and have it set so that when i'm coding in C one tab == 2 spaces (just a personal preference) Can't imagine using VS but the brackets on the same line is how i've always coded, can't imaging programming with them on their own line, TBH, it annoys me just thinking about it Anyway, updated the copy here. Added it so that it parses whitespace (can do ls (dash)la) (10-17-2016, 11:58 PM)Ao- Wrote: I don't have too much time right now, but I'll definitely try to break it laterI want to see you try :> Seriously, to anyone looking to fuck oversomeone elses code, rip apart mine. RE: Simple Shell Program - phyrrus9 - 10-18-2016 (10-18-2016, 05:44 AM)insidious15 Wrote:(10-18-2016, 12:36 AM)phyrrus9 Wrote:(10-18-2016, 12:25 AM)Ao- Wrote: Oh, god... Wait. Spaces or tabs? Take a look at getopt https://linux.die.net/man/3/getopt RE: Simple Shell Program - insidious - 10-18-2016 (10-17-2016, 11:58 PM)Ao- Wrote: I don't have too much time right now, but I'll definitely try to break it later (10-18-2016, 05:46 AM)phyrrus9 Wrote:(10-18-2016, 05:44 AM)insidious15 Wrote:(10-18-2016, 12:36 AM)phyrrus9 Wrote: Oh...yeah, making tabs be actual tabs (as it should be) is a pain in the ass with VS I was aware of something like this in the C libraries, but opted (hah, get it?) not to use it, mostly because i want all the C exp i can get, and wanted to stick with learning as much as possible about underlying functions still working on file handles, not totally certain how to go about that though. Is there another (closer-to-the-os) way of changing dirs? I understand the iNode structure of files/directories in UNIX, just not sure how that would be implemented in C. RE: Simple Shell Program - phyrrus9 - 10-18-2016 (10-18-2016, 05:51 AM)insidious15 Wrote:(10-17-2016, 11:58 PM)Ao- Wrote: I don't have too much time right now, but I'll definitely try to break it later Yep... you just dont change directory. Use your own pointer to hold that information. Or use a DIRENT. |