minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
pwd_builtin.c File Reference

Builtin function for the "pwd" command. More...

#include "minishell.h"
Include dependency graph for pwd_builtin.c:

Functions

int get_sizeof_args (char **args)
 Retrieves the number of arguments in an array of strings.
 
int pwd (void)
 Executes the "pwd" command to print the current working directory.
 

Detailed Description

Builtin function for the "pwd" command.

This file contains the implementation of the pwd builtin function for the minishell project. The pwd command is used to print the current working directory to the standard output.

Function Documentation

◆ get_sizeof_args()

int get_sizeof_args ( char **  args)

Retrieves the number of arguments in an array of strings.

This function counts the number of elements (arguments) in an array of strings and returns the count.

Parameters
[in]argsAn array of strings containing command arguments.
Returns
The number of arguments in the array.

◆ pwd()

int pwd ( void  )

Executes the "pwd" command to print the current working directory.

This function gets the current working directory using getcwd() and prints it to the standard output. If successful, it returns EXIT_SUCCESS; otherwise, it prints an error message and returns EXIT_FAILURE.

Returns
An exit status (EXIT_SUCCESS on success, or EXIT_FAILURE on failure).