Changeset 1c481ee in mainline for uspace/app/bdsh/compl.c


Ignore:
Timestamp:
2019-03-09T15:40:05Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
587867a
Parents:
c56a3eb
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-03-02 15:55:07)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-03-09 15:40:05)
Message:

This commit fixes #684 and adds autocompletion for subdirectories in search_path. The original implementation of find_command()
will find cmd inside the working directory even without
the prefix './'. However, those cmds would have not been visible in
the auto completion. This commit prevents this from happening.

The problem can be traced back to vfs_absolutize() which treats paths
without the './' prefix as relative paths. The changes made unsures
that only relative or absolute pathes will be passed to vfs_absolutize()

This commit also fixes the problem, that subdirectories inside the
search_path would not be autocomplete. BDSH would execute such paths.
The reason being is that such paths was interpreted as relative paths.
Now BDSH makes a distinction between relatives paths or paths inside
search_path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/compl.c

    rc56a3eb r1c481ee  
    4040#include "exec.h"
    4141#include "tok.h"
     42#include "util.h"
    4243
    4344static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state);
     
    209210                }
    210211                *cstart += rpath_sep + 1 - prefix;
    211                 free(prefix);
    212                 prefix = NULL;
    213212
    214213                cs->path_list = malloc(sizeof(char *) * 2);
     
    217216                        goto error;
    218217                }
    219                 cs->path_list[0] = dirname;
     218
     219                if (!is_path(prefix) && cs->is_command) {
     220                        cs->path_list[0] = malloc(sizeof(char) * PATH_MAX);
     221                        int ret = snprintf(cs->path_list[0], PATH_MAX, "%s/%s", search_dir[0], dirname);
     222                        if (ret < 0 || ret >= PATH_MAX) {
     223                                retval = ENOMEM;
     224                                goto error;
     225                        }
     226                } else {
     227                        cs->path_list[0] = dirname;
     228                }
     229
    220230                cs->path_list[1] = NULL;
    221231                /*
Note: See TracChangeset for help on using the changeset viewer.