Skip to content

kirolloushany03/simple_shell

Repository files navigation

Custom Shell - myshellk

What is the Shell?

The shell is a program that facilitates interaction with the operating system by accepting commands from the user through the terminal. It acts as an interface, forwarding user inputs to the operating system for execution.

About this Project

This project represents a custom shell, named simple_shell, developed for Holberton School as part of the "Low-level programming & Algorithm - Linux and Unix system programming" curriculum. Implemented in the C programming language, this shell introduces additional functionalities beyond a standard shell.

Essential Functionalities of simple_shell:

  • Displays a custom prompt "#Kiro$ " when in interactive mode.
  • Supports executing commands with arguments and handling absolute paths.
  • Handles built-in commands such as "exit" and "env."
  • Provides dynamic path resolution using the PATH environment variable.
  • Manages signals such as Ctrl + C gracefully, preventing accidental shell termination.

Files Description

  • command_exe.c:

    • printerror: Prints an error message when a command is not found.
    • execute_com: Forks a new process to execute a command using execve.
    • ex_com: Determines the path and returns the exit status of a command.
  • get_path_env.c:

    • find_env_key: Finds the value of an environment variable based on the key.
    • _getenv: Gets the value of an environment variable using the key.
    • is_absolute_path: Checks if a command is an absolute path.
    • search_in_path: Searches for a command in the directories specified by the PATH variable.
    • _getpath: Determines the path of a command, considering both absolute and relative paths.
  • king.c:

    • main: The main function serving as the entry point for the custom shell.
    • read_com: Reads the user input for a command line.
    • print_env: Prints environment variables.
    • _putchar: Writes a string to standard output.
  • simple_shell.h:

    • Header file containing function prototypes and necessary includes.
  • read_b_env.c:

    • read_com: Reads the user input for a command line.
    • print_env: Prints environment variables.
    • _putchar: Writes a string to standard output.
  • strings_3.c:

    • _strdup: Duplicates a string.
    • _strcmp: Compares two strings.
    • _strlen: Returns the length of a string.
    • _strcat: Concatenates two strings.
    • _strcpy: Copies a string.
  • tools_3.c:

    • reverse_str: Reverses a string.
    • _itoa: Converts an integer to a string.
    • freearray: Frees a dynamically allocated array of strings.
    • get_com_path: Gets the path of the input command.

List of Allowed Functions and System Calls for this Project

List of Allowed Functions and System Calls

The development of this custom shell adheres to the following list of allowed functions and system calls:

  • File System Manipulation:

  • Process Execution:

  • Input/Output:

  • Memory Management:

  • Directory Handling:

  • Signal Handling:

  • Process Termination:

  • File Operations:

    • open (man 2 open)
    • stat (__xstat) (man 2 stat)
    • lstat (__lxstat) (man 2 lstat)
    • fstat (__fxstat) (man 2 fstat)
  • String Manipulation:

  • Miscellaneous:

    • getcwd (man 3 getcwd)
    • isatty (man 3 isatty)
    • perror (man 3 perror)
    • (Feel free to add any additional functions or system calls as needed.)

For detailed information about each function or system call, refer to the provided man pages.

Usage

To experience our custom shell, follow these steps:

  1. Clone our repository using the command (ensure Git is installed):
git clone https://github.com/kirolloushany03/simple_shell
  1. Change directory to simple_shell:
cd simple_shell
  1. Compile the C files:
gcc -Wall -Werror -Wextra -pedantic *.c -o myshellk
  1. Run the shell:
./myshellk

Exiting the Shell

When exiting the shell, use one of the following methods:

  1. Type the command "exit":
exit
  1. Press Ctrl + D.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages