{"id":23617413,"url":"https://github.com/bshongwe/simple_shell","last_synced_at":"2025-07-26T22:15:32.039Z","repository":{"id":192964080,"uuid":"687816065","full_name":"bshongwe/simple_shell","owner":"bshongwe","description":"ALX Team Project","archived":false,"fork":false,"pushed_at":"2023-09-23T19:23:00.000Z","size":184,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T07:41:01.166Z","etag":null,"topics":["c-language-programming","unix-shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bshongwe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-06T04:14:23.000Z","updated_at":"2023-10-17T15:33:46.000Z","dependencies_parsed_at":"2023-09-21T23:19:54.857Z","dependency_job_id":null,"html_url":"https://github.com/bshongwe/simple_shell","commit_stats":null,"previous_names":["bshongwe/simple_shell"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bshongwe/simple_shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshongwe%2Fsimple_shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshongwe%2Fsimple_shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshongwe%2Fsimple_shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshongwe%2Fsimple_shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bshongwe","download_url":"https://codeload.github.com/bshongwe/simple_shell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshongwe%2Fsimple_shell/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267250816,"owners_count":24060034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-language-programming","unix-shell"],"created_at":"2024-12-27T18:28:50.880Z","updated_at":"2025-07-26T22:15:32.015Z","avatar_url":"https://github.com/bshongwe.png","language":"C","readme":"# 0x16. C - Simple Shell\n\n## General\n\n-  Who designed and implemented the original Unix operating system\n-  Who wrote the first version of the UNIX shell\n-  Who invented the B programming language (the direct predecessor to the C programming language)\n-  Who is Ken Thompson\n-  How does a shell work\n-  What is a pid and a ppid\n-  How to manipulate the environment of the current process\n-  What is the difference between a function and a system call\n-  How to create processes\n-  What are the three prototypes of main\n-  How does the shell use the PATH to find the programs\n-  How to execute another program with the execve system call\n-  How to suspend the execution of a process until one of its children terminates\n-  What is EOF / “end-of-file”?\n-  All your files should end with a new line\n-  A README.md file, at the root of the folder of the project is mandatory\n-  Your code should use the Betty style. It will be checked using betty-style.pl and betty-doc.pl\n-  Your shell should not have any memory leaks\n-  No more than 5 functions per file\n-  All your header files should be include guarded\n-  Use system calls only when you need to (why?)\n-  Write a README with the description of your project\n-  You should have an AUTHORS file at the root of your repository, listing all individuals having contributed content to the repository. Format, see Docker\n\n\n## GitHub\n\n*There should be one project repository per group. If you and your partner have a repository with the same name in both your accounts, you risk a 0% score. Add your partner as a collaborator. *\n\n\n## Output\n\nUnless specified otherwise, your program must have the exact same output as sh (/bin/sh) as well as the exact same error output.\nThe only difference is when you print an error, the name of the program must be equivalent to your argv[0]\n\n\n## List of allowed functions and system calls\n\n-  access (man 2 access)\n-  chdir (man 2 chdir)\n-  close (man 2 close)\n-  closedir (man 3 closedir)\n-  execve (man 2 execve)\n-  exit (man 3 exit)\n-  _exit (man 2 _exit)\n-  fflush (man 3 fflush)\n-  fork (man 2 fork)\n-  free (man 3 free)\n-  getcwd (man 3 getcwd)\n-  getline (man 3 getline)\n-  getpid (man 2 getpid)\n-  isatty (man 3 isatty)\n-  kill (man 2 kill)\n-  malloc (man 3 malloc)\n-  open (man 2 open)\n-  opendir (man 3 opendir)\n-  perror (man 3 perror)\n-  read (man 2 read)\n-  readdir (man 3 readdir)\n-  signal (man 2 signal)\n-  stat (__xstat) (man 2 stat)\n-  lstat (__lxstat) (man 2 lstat)\n-  fstat (__fxstat) (man 2 fstat)\n-  strtok (man 3 strtok)\n-  wait (man 2 wait)\n-  waitpid (man 2 waitpid)\n-  wait3 (man 2 wait3)\n-  wait4 (man 2 wait4)\n-  write (man 2 write)\n\n\n## Compilation\n\nYour shell will be compiled this way: \u003ccode\u003egcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh\u003c/code\u003e\n\n\n## Testing\n\nYour shell should work like this in interactive mode:\n\n    $ ./hsh\n    ($) /bin/ls\n    hsh main.c shell.c\n    ($)\n    ($) exit\n    $\n\nBut also in non-interactive mode:\n\n    $ echo \"/bin/ls\" | ./hsh\n    hsh main.c shell.c test_ls_2\n    $\n    $ cat test_ls_2\n    /bin/ls\n    /bin/ls\n    $\n    $ cat test_ls_2 | ./hsh\n    hsh main.c shell.c test_ls_2\n    hsh main.c shell.c test_ls_2\n    $\n\n## Checks\nWe strongly encourage the entire class to work together to create a suite of checks covering both regular tests and edge cases for each task. See task 8. Test suite.\n\n\u003ccode\u003eGitHub repository: simple_shell\u003c/code\u003e\n\n\n## Tasks\n### Task 0. Betty would be proud\n\nWrite a beautiful code that passes the Betty checks\n\n\n### Task 1. Simple shell 0.1\n\nWrite a UNIX command line interpreter.\n\nUsage: simple_shell\n\nYour Shell should:\n-  Display a prompt and wait for the user to type a command. A command line always ends with a new line.\n-  The prompt is displayed again each time a command has been executed.\n-  The command lines are simple, no semicolons, no pipes, no redirections or any other advanced features.\n-  The command lines are made only of one word. No arguments will be passed to programs.\n-  If an executable cannot be found, print an error message and display the prompt again.\n-  Handle errors.\n-  You have to handle the “end of file” condition (Ctrl+D)\n\nYou don’t have to:\n-  use the PATH\n-  implement built-ins\n-  handle special characters : \", ', `, \\, *, \u0026, #\n-  be able to move the cursor\n-  handle commands with arguments\n-  execve will be the core part of your Shell, don’t forget to pass the environ to it…\n\n    \n### Task 2. Simple shell 0.2\n\nSimple shell 0.1 +\nHandle command lines with arguments\n\n\n### Task 3. Simple shell 0.3\n\nSimple shell 0.2 +\nHandle the PATH\n-  fork must not be called if the command doesn’t exist\n\n    \n### Task 4. Simple shell 0.4\n\nSimple shell 0.3 +\nImplement the exit built-in, that exits the shell\n\nUsage: exit\nYou don’t have to handle any argument to the built-in exit\n\n    \n### Task 5. Simple shell 1.0\n\nSimple shell 0.4 +\nImplement the env built-in, that prints the current environment\n\n\n### Task 6. Simple shell 0.1.1\n\nSimple shell 0.1 +\nWrite your own getline function\n-  Use a buffer to read many chars at once and call the least possible the read system call\n-  You will need to use static variables\n-  You are not allowed to use getline\n\nYou don’t have to:\n-  be able to move the cursor\n\n    \n### Task 7. Simple shell 0.2.1\n\nSimple shell 0.2 +\nYou are not allowed to use strtok\n\n    \n### Task 8. Simple shell 0.4.1\n\nSimple shell 0.4 +\nhandle arguments for the built-in exit\n\nUsage: exit status, where status is an integer used to exit the shell\n\n    \n### Task 9. setenv, unsetenv\n\nSimple shell 1.0 +\nImplement the setenv and unsetenv builtin commands\n\nsetenv\n-  Initialize a new environment variable, or modify an existing one\n-  Command syntax: setenv VARIABLE VALUE\n-  Should print something on stderr on failure\n\nunsetenv\n-  Remove an environment variable\n-  Command syntax: unsetenv VARIABLE\n-  Should print something on stderr on failure\n\n    \n### Task 10. cd\n\nSimple shell 1.0 +\n\nImplement the builtin command cd:\n-  Changes the current directory of the process.\n-  Command syntax: cd [DIRECTORY]\n-  If no argument is given to cd the command must be interpreted like cd $HOME\n-  You have to handle the command cd\n-  You have to update the environment variable PWD when you change directory\n-  man chdir, man getcwd\n\n\n### Task 11. ;\n\nSimple shell 1.0 +\nHandle the commands separator ;\n\n\n### Task 12. \u0026\u0026 and ||\n\nSimple shell 1.0 +\nHandle the \u0026\u0026 and || shell logical operators\n\n\n### Task 13. alias\n\nSimple shell 1.0 +\nImplement the alias builtin command\n\nUsage: alias [name[='value'] ...]\n-  alias: Prints a list of all aliases, one per line, in the form name='value'\n-  alias name [name2 ...]: Prints the aliases name, name2, etc 1 per line, in the form name='value'\n-  alias name='value' [...]: Defines an alias for each name whose value is given. If name is already an alias, replaces its value with value\n\n\n### Task 14. Variables\n\nSimple shell 1.0 +\n-  Handle variables replacement\n-  Handle the $? variable\n-  Handle the $$ variable\n\n\n### Task 15. Comments\n\nSimple shell 1.0 +\nHandle comments (#)\n\n    \n### Task 16. File as input\n\nSimple shell 1.0 +\n\nUsage: simple_shell [filename]\n\n-  Your shell can take a file as a command line argument\n-  The file contains all the commands that your shell should run before exiting\n-  The file should contain one command per line\n-  In this mode, the shell should not print a prompt and should not read from stdin\n\n\nAuthors: Ernest Bhekizwe Shongwe, Garrick Larson Potts. (Credit to my Printf patner, Zikona  Mnyaka, for bringing this project ack to life)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbshongwe%2Fsimple_shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbshongwe%2Fsimple_shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbshongwe%2Fsimple_shell/lists"}