Subversion Repositories HelenOS

Rev

Rev 3267 | Rev 3278 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3267 Rev 3269
Line 62... Line 62...
62
    return CMD_VOID;
62
    return CMD_VOID;
63
}
63
}
64
 
64
 
65
/* This is a very rudamentary 'cd' command. It is not 'link smart' (yet) */
65
/* This is a very rudamentary 'cd' command. It is not 'link smart' (yet) */
66
 
66
 
67
int * cmd_cd(char *argv[], cliuser_t *usr)
67
int * cmd_cd(char **argv, cliuser_t *usr)
68
{
68
{
69
    int argc, rc = 0;
69
    int argc, rc = 0;
70
    char *dest = NULL;
-
 
71
 
70
 
72
    for (argc = 0; argv[argc] != NULL; argc ++);
71
    for (argc = 0; argv[argc] != NULL; argc ++);
73
 
72
 
74
    /* Someone just typed 'cd' , send them home */
-
 
75
 
-
 
76
    if (argc < 2)
-
 
77
        dest = cli_strdup(usr->home);
-
 
78
 
-
 
79
    /* We don't yet play nice with whitespace, a getopt implementation should
73
    /* We don't yet play nice with whitespace, a getopt implementation should
80
     * protect "quoted\ destination" as a single argument. Its not our job to
74
     * protect "quoted\ destination" as a single argument. Its not our job to
81
     * look for && || or redirection as the tokenizer should have done that
75
     * look for && || or redirection as the tokenizer should have done that
82
     * (currently, it does not) */
76
     * (currently, it does not) */
83
 
77
 
Line 87... Line 81...
87
    }
81
    }
88
 
82
 
89
    /* We have the correct # of arguments
83
    /* We have the correct # of arguments
90
     * TODO: handle tidle (~) expansion? */
84
     * TODO: handle tidle (~) expansion? */
91
 
85
 
92
    if (argc == 2)
-
 
93
        dest = cli_strdup(argv[1]);
86
    rc = chdir(argv[1]);
94
 
87
 
95
    rc = chdir(dest);
-
 
96
    if (rc == 0) {
88
    if (rc == 0) {
97
        free(dest);
-
 
98
        return CMD_SUCCESS;
89
        return CMD_SUCCESS;
99
    } else {
90
    } else {
100
        free(dest);
-
 
101
        switch (rc) {
91
        switch (rc) {
102
        case ENOMEM:
92
        case ENOMEM:
103
            cli_error(CL_EFAIL, "Destination path too long");
93
            cli_error(CL_EFAIL, "Destination path too long");
104
            break;
94
            break;
105
        case ENOENT:
95
        case ENOENT: