C-Shell
A simple shell written in C.
Loading...
Searching...
No Matches
redirection.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "shelltypes.h"

Functions

void show_error (char *file)
 
int handle_redirection (struct command *cmd)
 Handles redirections for a command.
 

Function Documentation

◆ handle_redirection()

int handle_redirection ( struct command * cmd)

Handles redirections for a command.

Parses the command's arguments and sets the file descriptors for input, output, and error. If a file is not found, the function will print an error message and return -1.

Command arguments are modified in place to remove the redirection symbols and the file names. The file descriptors must be standard input/output/error. Otherwise, the function will print an error message and return -1.

Parameters
cmd
Returns
0 on success, -1 on error

◆ show_error()

void show_error ( char * file)