NSH ls command should strip any trailing '/' characters from paths
This commit is contained in:
parent
f48d95e941
commit
0c03c1e840
@ -1006,6 +1006,7 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
unsigned int lsflags = 0;
|
unsigned int lsflags = 0;
|
||||||
char *fullpath;
|
char *fullpath;
|
||||||
bool badarg = false;
|
bool badarg = false;
|
||||||
|
int len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Get the ls options */
|
/* Get the ls options */
|
||||||
@ -1071,6 +1072,15 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Trim any trailing '/' characters */
|
||||||
|
|
||||||
|
len = strlen(fullpath) - 1;
|
||||||
|
while (len > 0 && fullpath[len] == '/')
|
||||||
|
{
|
||||||
|
fullpath[len] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
/* See if it is a single file */
|
/* See if it is a single file */
|
||||||
|
|
||||||
if (stat(fullpath, &st) < 0)
|
if (stat(fullpath, &st) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user