From 42abbc8f06fb56761502824b8085516299535534 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Mon, 9 Feb 2026 23:48:22 -0600 Subject: - readme. todo - update pwd - update SHLVL - basename pwd in prompt - updating pwd --- src/lsh_builtins.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/lsh_builtins.c') diff --git a/src/lsh_builtins.c b/src/lsh_builtins.c index 33b1b88..81fc2b5 100644 --- a/src/lsh_builtins.c +++ b/src/lsh_builtins.c @@ -44,9 +44,18 @@ int lsh_cd(char **args) if (args[1] == NULL) { fprintf(stderr, "lsh: expected argument to \"cd\"\n"); } else { - if (chdir(args[1]) != 0) { + int err = chdir(args[1]); + if (err != 0) { perror("lsh"); } + char *cwd=(char*)malloc(sizeof(char)*4096); + if (!cwd) { + fprintf(stderr, "lsh: allocation error\n"); + exit(EXIT_FAILURE); + } + getcwd(cwd,sizeof(char*)*4096); + setenv("PWD",cwd,1); + free(cwd); } return 1; } @@ -54,7 +63,7 @@ int lsh_cd(char **args) int lsh_help(char **args) { int i; - printf("Stephen Brennan's LSH\n"); + printf("FOX SHELL\n"); printf("Type program names and arguments, and hit enter.\n"); printf("The following are built in:\n"); -- cgit v1.3