Code Monkey home page Code Monkey logo

g-shell's Introduction

g-Shell

Description

g-Shell is a simple UNIX shell implementation written in C language. The shell provides a simple and efficient command line interface for users to interact with the operating system. The implementation of gShell includes built-in commands and the ability to run external programs.

Code Design

The gShell code consists of several functions, including a parser, handler, cd_command, export_command, echo_command, and main.

The parser function takes a command entered by the user and parses it into an array of arguments that can be passed to other functions. The maximum number of arguments allowed in the terminal is 10.

The handler function is responsible for handling SIGCHLD signals generated by the child process when it terminates. The parent process removes the process that initiated the signal from the processes table. In case of a zombie process, this method is responsible for reaping it.

The cd_command function is a built-in command for handling user commands to navigate between different directories. The function allows the user to navigate to the home directory, navigate up one level, or navigate to the previous directory.

The export_command function is a built-in command for defining environment variables and using them in child processes.

The echo_command function is a built-in command for printing the input line as a string of text or the value of a defined environment variable.

The main function is responsible for handling user input, parsing the command, and executing it. The main function also handles the built-in commands.

Specification

Implemented using c language along with unistd ans sys libraries

The following table shows the current set of commands supported by the shell:

Command Arguments Description
cd '', ~, /, .., - Changes the current working directory
pwd None Writes to standard output the full path name of your current directory (from the root directory)
ls ~, /, .., -, -l, -sl, -R, -a Displays the contents of a directory
mkdir Directory name Creates a new directory in the Linux/Unix operating system
rm Directory name, -r Deletes file or directory
ps aux, eaf views information related with the processes on a system
kill -, -s, -p Sends the specified signal to the specified processes or process groups
export Expression Marks variables and functions to be passed to child processes
find -H, -L Path locates files based on some user-specified criteria
echo $Variable Displays a line of string that is passed as the arguments or value of an environment variable
Process name & Runs the process as a backgroud process

References

g-shell's People

Contributors

mostafagalal1 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

youssefemad1222

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.