Skip to content

42Seoul-Cahn-Sangwoki/42_MiniShell

Repository files navigation

minishell

구현 목표

Bash-like shell 구현하기

참고 문헌: Bash Reference Manual

구현

  1. Searching for Commands in the History
  2. 상대 경로, 절대 경로를 기반으로 검색하고 실행해야 한다.
  3. built-in 함수: echo -n, cd, pwd, export, unset, env, exit, redirections, pipelines 등
  4. $?을 검색했을 때, 최근 실행된 프로세스의 종료 상태가 출력된다.
  5. shell에서 SIGINT(ctrl-c), EOF(ctrl-D), SIGQUIT(ctrl-\)가 작동되어야 한다.

실행 내용

make
./minishell

make로 Makefile을 실행하여 C언어 파일을 컴파일하고, minishell을 실행한다.

minishell 내부에서 Bash 명령어를 실행한다.

redirections

  1. Redirecting Input
  2. Redirecting Output
  3. Here Documents

아래의 그림은, Redirecting ouput과 Here Documents 명령어 실행 화면 입니다.

redirections

Redirecting output과 Redirecting input 명령어 실행 화면 입니다.

redirection2

pipelines

sleep 5 | sleep 3

아래의 그림을 통해 pipelines를 통해 2개의 프로세스가 병렬적으로 실행되었다는 것을 알 수 있습니다.

pipelines

echo, cd, pwd, ls

echo, cd, pwd, ls의 명령어가 정확히 동작하는 것을 알 수 있습니다.

Screen Shot 2024-05-16 at 5 36 35 PM

export, unset, env

export를 통해 환경 변수를 등록하고, unset을 통해 등록된 변수를 해제합니다.

이를 env 명령어로 확인할 수 있습니다.

export로 환경 변수를 등록합니다.

Screen Shot 2024-05-16 at 5 42 42 PM

unset으로 등록된 환경 변수를 제거합니다.

Screen Shot 2024-05-16 at 5 43 17 PM

$?과 SIGNAL

$?을 통해 종료 상태를 확인할 수 있습니다.

Screen Shot 2024-05-16 at 5 46 59 PM

About

'Documentation for GNU Bash'을 참고하여 만든 bash

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •