MiniDevil As beautiful as a shell
builtin_exit.c File Reference

Implements exit: shell exit with optional status. More...

#include "builtins.h"
#include "libft.h"
+ Include dependency graph for builtin_exit.c:

Detailed Description

Implements exit: shell exit with optional status.

Definition in file builtin_exit.c.

Functions

int builtin_exit (char **args, t_shell *shell)
 Implement the exit command. More...
 

Function Documentation

◆ builtin_exit()

int builtin_exit ( char **  args,
t_shell shell 
)

Implement the exit command.

  • Prints "exit" in interactive mode
  • With no args it exits with the current exit_status
  • With 1 numeric arg it exits with that code (casted to unsigned char)
  • With non numeric args it exits with 2
  • Too many args = error but does not exit (return 1)
Parameters
argsNULL terminated arg array with arg[0] = "exit"
shellShell context (running flag set to 0 in order to trigger exit)
Returns
Exit code (0-255) or 1 if too many args (and shell keeps running)

Definition at line 29 of file builtin_exit.c.

References t_shell::exit_status, t_shell::interactive, and t_shell::running.

Referenced by exec_builtin().

+ Here is the caller graph for this function:

Go to the source code of this file.