mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 12:16:31 +00:00
Patch about auto gen version string (#114)
* new: about app中,显示当前构建的git commit sha1以及构建时间 * bugfix: 修复shell的exec命令对绝对路径的拼接错误问题
This commit is contained in:
@ -39,26 +39,38 @@ const static int total_built_in_cmd_num = sizeof(shell_cmds) / sizeof(struct bui
|
||||
*/
|
||||
static char *get_target_filepath(const char *filename, int *result_path_len)
|
||||
{
|
||||
int cwd_len = strlen(shell_current_path);
|
||||
char *file_path = NULL;
|
||||
if (filename[0] != '/')
|
||||
{
|
||||
int cwd_len = strlen(shell_current_path);
|
||||
|
||||
// 计算文件完整路径的长度
|
||||
*result_path_len = cwd_len + strlen(filename);
|
||||
// 计算文件完整路径的长度
|
||||
*result_path_len = cwd_len + strlen(filename);
|
||||
|
||||
char *file_path = (char *)malloc(*result_path_len + 2);
|
||||
file_path = (char *)malloc(*result_path_len + 2);
|
||||
|
||||
memset(file_path, 0, *result_path_len + 2);
|
||||
memset(file_path, 0, *result_path_len + 2);
|
||||
|
||||
strcpy(file_path, shell_current_path);
|
||||
strncpy(file_path, shell_current_path, cwd_len);
|
||||
|
||||
// 在文件路径中加入斜杠
|
||||
if (cwd_len > 1)
|
||||
file_path[cwd_len] = '/';
|
||||
// 在文件路径中加入斜杠
|
||||
if (cwd_len > 1)
|
||||
file_path[cwd_len] = '/';
|
||||
|
||||
// 拼接完整路径
|
||||
if (filename[0] == '/')
|
||||
strcat(file_path, filename + 1);
|
||||
else
|
||||
// 拼接完整路径
|
||||
strcat(file_path, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
*result_path_len = strlen(filename);
|
||||
file_path = (char *)malloc(*result_path_len + 2);
|
||||
|
||||
memset(file_path, 0, *result_path_len + 2);
|
||||
|
||||
strncpy(file_path, filename, *result_path_len);
|
||||
if(filename[(*result_path_len)-1]!='/')
|
||||
file_path[*result_path_len] = '/';
|
||||
}
|
||||
|
||||
return file_path;
|
||||
}
|
||||
@ -483,7 +495,8 @@ int shell_cmd_exec(int argc, char **argv)
|
||||
// 如果不指定后台运行,则等待退出
|
||||
if (strcmp(argv[argc - 1], "&") != 0)
|
||||
waitpid(pid, &retval, 0);
|
||||
else{
|
||||
else
|
||||
{
|
||||
// 输出子进程的pid
|
||||
printf("[1] %d\n", pid);
|
||||
}
|
||||
|
Reference in New Issue
Block a user