Minishell 1.0
42 School Minishell Project - A simple shell implementation
Yüklüyor...
Arıyor...
Eşleşme Yok
builtin_pwd.c
Bu dosyanın dokümantasyonuna git.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* builtin_pwd.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: hgenc <hgenc@student.42kocaeli.com.tr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/01/17 18:42:00 by hgenc #+# #+# */
9/* Updated: 2026/02/19 20:00:00 by hgenc ### ########.fr */
10/* */
11/* ************************************************************************** */
12
14#include <stdlib.h>
15#include <unistd.h>
16
17/*
18** pwd builtin - logical cwd'yi yazdırır ($PWD env var kullanır)
19** macOS'ta getcwd() symlink'leri çözer (/tmp -> /private/tmp)
20** $PWD mantıksal yolu saklar (bash uyumlu davranış)
21*/
23{
24 char *pwd;
25 char *cwd;
26
27 pwd = get_env_value(shell->env_list, "PWD");
28 if (pwd)
29 {
30 ft_putendl_fd(pwd, STDOUT_FILENO);
31 return (0);
32 }
33 cwd = getcwd(NULL, 0);
34 if (!cwd)
35 {
36 perror("minishell: pwd");
37 return (1);
38 }
39 ft_putendl_fd(cwd, STDOUT_FILENO);
40 free(cwd);
41 return (0);
42}
int builtin_pwd(t_shell *shell)
Definition builtin_pwd.c:22
char * get_env_value(t_list *env_list, char *key)
Environment listesinde key'e göre değer döndürür.
Definition env_utils.c:73
Minishell ana header dosyası
struct s_shell t_shell
t_list * env_list
Definition minishell.h:149