{"id":17533065,"url":"https://github.com/anny85-code/simple_shell","last_synced_at":"2026-05-16T11:01:42.627Z","repository":{"id":119495823,"uuid":"567862014","full_name":"Anny85-code/simple_shell","owner":"Anny85-code","description":"0x16. C - Simple Shell","archived":false,"fork":false,"pushed_at":"2022-11-19T00:59:36.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T17:40:14.280Z","etag":null,"topics":["c","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/Anny85-code.png","metadata":{"files":{"readme":"README.md","changelog":"history.c","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,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-11-18T18:59:29.000Z","updated_at":"2022-11-19T00:22:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ae49c3f-9e8a-4639-b6e6-1f91a4932520","html_url":"https://github.com/Anny85-code/simple_shell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Anny85-code/simple_shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anny85-code%2Fsimple_shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anny85-code%2Fsimple_shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anny85-code%2Fsimple_shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anny85-code%2Fsimple_shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anny85-code","download_url":"https://codeload.github.com/Anny85-code/simple_shell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anny85-code%2Fsimple_shell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","shell"],"created_at":"2024-10-20T18:23:05.455Z","updated_at":"2026-05-16T11:01:42.621Z","avatar_url":"https://github.com/Anny85-code.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Shell project 0x16.c \n\nThis is a simple UNIX command interpreter based on bash and Sh.\n\n## Overview\n\n**Simple-shell** is a sh-compatible command language interpreter that executes commands read from the standard input or from a file.\n\n### Invocation\n\nUsage: **Simple-shell** \nSimple-shell is started with the standard input connected to the terminal. To start, compile all .c located in this repository by using this command: \n```\ngcc -Wall -Werror -Wextra -pedantic *.c -o simple_shell\n./simple_shell\n```\n\n**Simple-shell** is allowed to be invoked interactively and non-interactively. If **simple-shell** is invoked with standard input not connected to a terminal, it reads and executes received commands in order.\n\nExample:\n```\n$ echo \"echo 'alx'\" | ./simple-shell\n'africa'\n$\n```\n\nWhen **simple-shell** is invoked with standard input connected to a terminal (determined by isatty(3), the interactive mode is opened. **simple-shell** Will be using the following prompt `^-^ `.\n\nExample:\n```\n$./simple-shell\n^-^\n```\n\nIf a command line argument is invoked, **simple-shell** will take that first argument as a file from which to read commands.\n\nExample:\n```\n$ cat text\necho 'alx'\n$ ./simple_shell text\n'africa'\n$\n```\n\n### Environment\n\nUpon invocation, **simple-shell** receives and copies the environment of the parent process in which it was executed. This environment is an array of *name-value* strings describing variables in the format *NAME=VALUE*. A few key environmental variables are:\n\n#### HOME\nThe home directory of the current user and the default directory argument for the **cd** builtin command.\n\n```\n$ echo \"echo $HOME\" | ./simple_shell\n/home/vagrant\n```\n\n#### PWD\nThe current working directory as set by the **cd** command.\n\n```\n$ echo \"echo $PWD\" | ./simple_shell\n/home/vagrant/alx/simple_shell\n```\n\n#### OLDPWD\nThe previous working directory as set by the **cd** command.\n\n```\n$ echo \"echo $OLDPWD\" | ./simple_shell\n/home/vagrant/holberton/bog-062019-test_suite\n```\n\n#### PATH\nA colon-separated list of directories in which the shell looks for commands. A null directory name in the path (represented by any of two adjacent colons, an initial colon, or a trailing colon) indicates the current directory.\n\n```\n$ echo \"echo $PATH\" | ./simple_shell\n/home/vagrant/.cargo/bin:/home/vagrant/.local/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/home/vagrant/.nvm/versions/node/v10.15.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/vagrant/.cargo/bin:/home/vagrant/workflow:/home/vagrant/.local/bin\n```\n\n### Command Execution\n\nAfter receiving a command, **simple-shell** tokenizes it into words using `\" \"` as a delimiter. The first word is considered the command and all remaining words are considered arguments to that command. **simple-shell** then proceeds with the following actions:\n1. If the first character of the command is neither a slash (`\\`) nor dot (`.`), the shell searches for it in the list of shell builtins. If there exists a builtin by that name, the builtin is invoked.\n2. If the first character of the command is none of a slash (`\\`), dot (`.`), nor builtin, **sodash** searches each element of the **PATH** environmental variable for a directory containing an executable file by that name.\n3. If the first character of the command is a slash (`\\`) or dot (`.`) or either of the above searches was successful, the shell executes the named program with any remaining given arguments in a separate execution environment.\n\n### Exit Status \n\n**simple-shell** returns the exit status of the last command executed, with zero indicating success and non-zero indicating failure.\nIf a command is not found, the return status is 127; if a command is found but is not executable, the return status is 126.\nAll builtins return zero on success and one or two on incorrect usage (indicated by a corresponding error message).\n\n### Signals\n\nWhile running in interactive mode, **simple-shell** ignores the keyboard input ctrl+c. Alternatively, an input of End-Of-File ctrl+d will exit the program.\n\nUser hits ctrl+d in the foutrh command.\n```\n$ ./simple_shell\n^-^ ^C\n^-^ ^C\n^-^ ^C\n^-^\n```\n\n### Variable Replacement\n\n**simple-shell** interprets the `$` character for variable replacement.\n\n#### $ENV_VARIABLE\n`ENV_VARIABLE` is substituted with its value.\n\nExample:\n```\n$ echo \"echo $PWD\" | ./simple_shell\n/home/vagrant/alx/simple_shell\n```\n\n#### $?\n`?` is substitued with the return value of the last program executed.\n\nExample:\n```\n$ echo \"echo $?\" | ./simple_shell\n0\n```\n\n#### $$\nThe second `$` is substitued with the current process ID.\n\nExample:\n```\n$ echo \"echo $$\" | ./simple_shell\n3855\n```\n\n### Comments\n\n**simple-shell** ignores all words and characters preceeded by a `#` character on a line.\n\nExample:\n```\n$ echo \"echo 'alx' #this will be ignored!\" | ./simple_shell\n'africa'\n```\n\n### Operators\n\n**simple-shell** specially interprets the following operator characters:\n\n#### ; - Command separator\nCommands separated by a `;` are executed sequentially.\n\nExample:\n```\n$ echo \"echo 'hello' ; echo 'world'\" | ./simple_shell\n'hello'\n'world'\n```\n\n#### \u0026\u0026 - AND logical operator\n`command1 \u0026\u0026 command2`: `command2` is executed if, and only if, `command1` returns an exit status of zero.\n\nExample:\n```\n$ echo \"error! \u0026\u0026 echo 'alx'\" | ./simple_shell\n./shellby: 1: error!: not found\n$ echo \"echo 'my name is' \u0026\u0026 echo 'alx'\" | ./simpe_shell\n'my name is'\n'africa'\n```\n\n#### || - OR logical operator\n`command1 || command2`: `command2` is executed if, and only if, `command1` returns a non-zero exit status.\n\nExample:\n```\n$ echo \"error! || echo 'wait for it'\" | ./simple_shell\n./simple_shell: 1: error!: not found\n'wait for it'\n```\n\nThe operators `\u0026\u0026` and `||` have equal precedence, followed by `;`.\n\n### Builtin Commands\n\n#### cd\n  * Usage: `cd [DIRECTORY]`\n  * Changes the current directory of the process to `DIRECTORY`.\n  * If no argument is given, the command is interpreted as `cd $HOME`.\n  * If the argument `-` is given, the command is interpreted as `cd $OLDPWD` and the pathname of the new working directory is printed to standad output.\n  * If the argument, `--` is given, the command is interpreted as `cd $OLDPWD` but the pathname of the new working directory is not printed.\n  * The environment variables `PWD` and `OLDPWD` are updated after a change of directory.\n\nExample:\n```\n$ ./simple_shell\n^-^ pwd\n/home/vagrant/alx/simple_shell\n$ cd ../\n^-^ pwd\n/home/vagrant/alx\n^-^ cd -\n^-^ pwd\n/home/vagrant/alx/simple_shell\n```\n\n#### exit\n  * Usage: `exit [STATUS]`\n  * Exits the shell.\n  * The `STATUS` argument is the integer used to exit the shell.\n  * If no argument is given, the command is interpreted as `exit 0`.\n\nExample:\n```\n$ ./simple_shell\n$ exit\n```\n\n#### env\n  * Usage: `env`\n  * Prints the current environment.\n\nExample:\n```\n$ ./simple_shell\n$ env\nNVM_DIR=/home/vagrant/.nvm\n...\n```\n\n#### setenv\n  * Usage: `setenv [VARIABLE] [VALUE]`\n  * Initializes a new environment variable, or modifies an existing one.\n  * Upon failure, prints a message to `stderr`.\n\nExample:\n```\n$ ./simple_shell\n$ setenv NAME Holberton\n$ echo $NAME\nHolberton\n```\n\n#### unsetenv\n  * Usage: `unsetenv [VARIABLE]`\n  * Removes an environmental variable.\n  * Upon failure, prints a message to `stderr`.\n\nExample:\n```\n$ ./simple_shell\n$ setenv NAME Alx Africa\n$ unsetenv NAME\n$ echo $NAME\n\n$\n```\n\n## Authors \u0026 Copyrights\n\n* Aniekan Udo \u003c[Aniekan Udo](https://www.linkedin.com/in/aniekan-udo)\u003e\n* Olibrahim \u003c[Olibrahim](https://github.com/Olibrahim)\u003e\n\n## More information\n\n**Simple-shell** is a simple shell unix command interpreter that is part of the alx-africa low level programming module at Alx Africa and is intended to emulate the basics **sh** shell. All the information given in this README is based on the **simple-shell** and **bash** man (1) pages.   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanny85-code%2Fsimple_shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanny85-code%2Fsimple_shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanny85-code%2Fsimple_shell/lists"}