diff options
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"); |
