diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-02-09 23:48:22 -0600 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-02-09 23:48:22 -0600 |
| commit | 42abbc8f06fb56761502824b8085516299535534 (patch) | |
| tree | 70fc16f235b3b5346774dc098cac2c8dcf60549d /src/lsh_builtins.c | |
| parent | f1f01cbbf9681ee311a69db40e832c630950cb53 (diff) | |
- readme. todo
- update pwd
- update SHLVL
- basename pwd in prompt
- updating pwd
Diffstat (limited to 'src/lsh_builtins.c')
| -rw-r--r-- | src/lsh_builtins.c | 13 |
1 files changed, 11 insertions, 2 deletions
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"); |
