## RunDialog

RunDialog

## Functions

array | completeCommand ()

## Functions

### completeCommand ()

    array
    completeCommand (string   text);

This function finds possible command completions for `text`. `text` is first split at whitspaces, and completion is performed on the last segment. Note that this currently does not recognize escaped whitspaces.

If the last segment starts with a `/`, then it is considered to be an absolute path. Otherwise, if it is the first segment (ie. there is only one segment), it will be treated as a path relative to the home directory or a path relative to an element of `PATH`. Finally, if it is not an absolute path and not a first segment, it will be treated as a path relative to the home directory.

To perform the completion, first the directory of the last segment is calculated. For example, if the last segment is `/foo/bar/hel`, then the directory is `/foo/bar/`. Then everything in the directory is listed, and it checks which items starts with `hel`. All the items will then be listed in the `completions` array. The common part of all possible completions is put in the `postfix` variable, and the tuple `[postfix, completions]` is returned.

It is important to note that the returned variables are just the part added by completion. So if `/foo/bar/hel` completes to `/foo/bar/hello`, then `lo` is returned, instead of `/foo/bar/hello`. This is the case for both the `postfix` and `completions` part.

A special case is when the last segment is empty. In this case, an empty tuple is returned.

#### Parameters

text | initial string to complete. |

#### Returns

The tuple `[postfix, completions]`.