GithubHelp home page GithubHelp logo

42_minishell's Introduction

Project overview

This project is about recreating our own version of bash with limited functionality. A miniature shell :).

Permitted functions and their description

Function Description
readline Reads a line from the terminal.
rl_clear_history Clears the history of readline.
rl_on_new_line Prepares readline for a new line of input.
rl_replace_line Replaces the current line buffer in readline.
rl_redisplay Redisplay the line buffer in readline.
add_history Adds a line to the history in readline.
printf Prints formatted output to stdout.
malloc Allocates a block of memory.
free Frees a block of allocated memory.
write Writes data to a file descriptor.
access Checks the accessibility of a file.
open Opens a file descriptor.
read Reads data from a file descriptor.
close Closes a file descriptor.
fork Creates a new process.
wait Waits for a child process to terminate.
waitpid Waits for a specific child process to terminate.
wait3 Waits for any child process, returning resource usage.
wait4 Waits for any child process, specifying options and returning resource usage.
signal Sets a function to handle a signal.
sigaction Examines or changes the action for a specific signal.
sigemptyset Initializes a signal set to be empty.
sigaddset Adds a signal to a signal set.
kill Sends a signal to a process or a group of processes.
exit Terminates the calling process.
getcwd Gets the current working directory.
chdir Changes the current working directory.
stat Retrieves information about a file based on its filename.
lstat Like stat, but for symbolic links.
fstat Retrieves information about a file based on its file descriptor.
unlink Removes a file from the filesystem.
execve Executes a program, replacing the current process.
dup Duplicates a file descriptor.
dup2 Duplicates a file descriptor to a given value.
pipe Creates a pair of file descriptors for interprocess communication.
opendir Opens a directory stream.
readdir Reads a directory entry from a directory stream.
closedir Closes a directory stream.
strerror Returns a string describing an error code.
perror Prints an error message to stderr.
isatty Tests whether a file descriptor refers to a terminal.
ttyname Returns the name of a terminal.
ttyslot Finds the slot of the current user's terminal in the utmp file.
ioctl Manipulates the underlying device parameters of special files.
getenv Retrieves the value of an environment variable.
tcsetattr Sets the parameters associated with the terminal.
tcgetattr Gets the parameters associated with the terminal.
tgetent Loads the terminal entry.
tgetflag Checks for the presence of a capability in the terminal description.
tgetnum Retrieves a numeric capability from the terminal description.
tgetstr Retrieves a string capability from the terminal description.
tgoto Decodes a cursor motion string.
tputs Puts a terminal string with padding.

Test cases

Simple commands with absolute path

/bin/ls src
/bin/pwd hello
/bin/date
/usr/bin/head -n 10 Makefile
/bin/grep # Makefile
/usr/bin/uname -a
/usr/bin/head Makefile
/usr/bin/tail Makefile

Valgrind

valgrind -s --leak-check=full --show-reachable=yes --error-limit=no --suppressions=minishell.supp --trace-children=yes --track-fds=yes ./minishell

  • -s: same as --show-error-list=yes that shows detected errors list and suppression count at exit
  • --leak-check=full: shows a full list of memory leaks
  • --show-reachable=yes: same as --show-leak-kinds=all that shows all kinds of memory leaks
  • --error-limit=no: won't stop showing errors if too many
  • --suppressions=minishell.supp: suppresses memory leaks from in-built functions (readline and add_history)
  • --trace-children=yes: checks memory leaks in child process too
  • --track-fds=yes: tracks open and closed file descriptors

42_minishell's People

Contributors

andreaulicna avatar sl16 avatar

Stargazers

Chinwendu Agbaetuo avatar Abdelhalim El Ouardy avatar

Watchers

 avatar

Forkers

sl16

42_minishell's Issues

Set prompt

Example: aulicna@c2r2s1:~/42_cursus/42_minishell$

When to init and free env?

If we use the current free_data function, we need to init env in every run (every new prompt) of minishell. But that way we lose any changes to it (e.g. adding/ removing a variable). So we likely need to change the free_data function. Possibly by adding a code to indicate whether or not we need to exit minishell or just produce a new prompt.

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.