Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/builtins/cd/cd.c

    r089385e8 r36ab7c7  
    6363        argc = cli_count_args(argv);
    6464
    65         /* Handle cd -- -. Override to switch to a directory named '-' */
    66         bool hyphen_override = false;
    67         if (argc == 3) {
    68                 if(!str_cmp(argv[1], "--")) {
    69                         hyphen_override = true;
    70                         argc--;
    71                 }
    72         }
    73 
    7465        /* We don't yet play nice with whitespace, a getopt implementation should
    7566         * protect "quoted\ destination" as a single argument. Its not our job to
     
    8879        }
    8980
    90         /* We have the correct # of arguments */
    91         // TODO: handle tidle (~) expansion? */
     81        /* We have the correct # of arguments
     82     * TODO: handle tidle (~) expansion? */
    9283
    93         /* Handle 'cd -' first. */
    94         if (!str_cmp(argv[1], "-") && !hyphen_override) {
    95                 char *buffer = (char *) malloc(PATH_MAX);
    96                 if (!buffer) {
    97                         cli_error(CL_ENOMEM, "Cannot switch to previous directory");
    98                         return CMD_FAILURE;
    99                 }
    100                 memset(buffer, 0, PATH_MAX);
    101                 getprevwd(buffer, PATH_MAX);
    102                 if (*buffer == '\0') {
    103                         cli_error(CL_EFAIL, "No previous directory to switch to");
    104                         free(buffer);
    105                         return CMD_FAILURE;
    106                 } else {
    107                         rc = chdir(buffer);
    108                         free(buffer);
    109                 }
    110         } else if (hyphen_override) {
    111                 /* Handles 'cd -- <dirname>'.
    112                  * Override for directory named '-'.
    113                  */
    114                 rc = chdir(argv[2]);
    115         } else {
    116                 rc = chdir(argv[1]);
    117         }
     84        rc = chdir(argv[1]);
    11885
    11986        if (rc == 0) {
Note: See TracChangeset for help on using the changeset viewer.