int do_chdir(char *path) { char *pwd; if (chdir(path) != 0) { shell_warn("cd: chdir() failed.\n"); return -1; } if ((pwd = sh_getenv("PWD")) != NULL) { sh_setenv("OLDPWD", pwd); } else sh_unsetenv("OLDPWD"); set_pwd(); return 0; }
static void handle_cd_to(t_state *state, char *cd_to) { struct stat statt; if (!is_exist_cmd(cd_to)) print_no_such_file_or_dir(state, "cd", cd_to); else if (stat(cd_to, &statt) && !S_ISDIR(statt.st_mode)) print_not_a_directory(state, "cd", cd_to); else if (!is_exec_cmd(cd_to)) print_permission_denied(state, "cd", cd_to); else { set_oldpwd(state); set_pwd(state, cd_to); } }
/* Change the working directory */ static int builtin_cd(unsigned argc, const char **argv) { int ret = 1; const char *dest_dir; if (argc) { dest_dir = argv[0]; } else { dest_dir = lookup_shell_param("HOME"); if (!dest_dir) { mysh_error("cd: HOME not set"); goto out; } } if (chdir(dest_dir) != 0) mysh_error_with_errno("cd: %s", dest_dir); else ret = set_pwd(); out: return ret; }
void init_pwd() { sh_unsetenv("OLDPWD"); set_pwd(); }
/************************************************* Function: setUserPassword Description: 设置用户密码 Input: password 用户密码 Output: 无 Return: 无 Others: *************************************************/ void operGuiStorage::setUserPassword(QString password) { set_pwd(OWNER_SECU_PWD, password.toLatin1().data()); }
/************************************************* Function: setProjectPassword Description: 设置工程密码 Input: password 工程密码 Output: 无 Return: 无 Others: *************************************************/ void operGuiStorage::setProjectPassword(QString password) { set_pwd(ADMIN_PWD, password.toLatin1().data()); }