Skip to content

Commit

Permalink
apps/nshlib/cmd_cd: Modify the logic of cd
Browse files Browse the repository at this point in the history
Modify the implementation logic of changing directory.
There's an error handling the path incluing "../" or "./"

bug examples:

nsh> cd proc/self/group
nsh> cd ../..
nsh: cd: chdir failed: 2

nsh> pwd
/proc/self
nsh> ls
/proc/self:
 status
 cmdline
 stack
 group/
nsh> cd ./group
nsh: cd: chdir failed: 2

Signed-off-by: zhengyu9 <[email protected]>
  • Loading branch information
zhengyu9 authored and xiaoxiang781216 committed Oct 17, 2024
1 parent 59c21c7 commit 697e3be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nshlib/nsh_fsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ FAR char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
snprintf(vtbl->iobuffer, IOBUFFERSIZE, "%s/%s", dirpath, path);
}

return strdup(vtbl->iobuffer);
return lib_realpath(vtbl->iobuffer, NULL, true);
}
#endif

Expand Down

0 comments on commit 697e3be

Please sign in to comment.