Пример #1
0
void cmd::fn_cd(inode_state& state, const util::wordvec& args) {
    DEBUGF('c', state);
    DEBUGF('c', args);
    if (args.size() > 1) {
        throw util::yshell_exn("cd: Expecting only one path arg");
    }
    // If: empty args, cd to root (ie "/")
    //   elif: args[0] is "/" then cd to root
    //   else: split args[0] on "/" & cd
    state.cd(args.size() == 0
            ? util::wordvec{"/"}
            : (args[0] == "/"
                ? util::wordvec{"/"}
                : util::split(args[0], "/")));
}