function complete( out, expression, alias, path ) {
	var filter;
	var subdir;
	var files;
	var stats;
	var args;
	var ast;
	var arg;
	var dir;
	var f;
	var i;

	// Get the list of argument types for the desired file system API:
	debug( 'File system API: %s', alias );
	args = fsAliasArgs( alias );

	// Parse the expression into an AST:
	debug( 'Expression: %s', expression );
	ast = parse( expression, AOPTS );

	// Check whether the argument which triggered TAB completion has a corresponding argument type which is completable:
	debug( 'Checking if argument is completable...' );
	arg = args[ ast.body[ 0 ].expression.arguments.length-1 ];
	if ( !arg ) {
		debug( 'Argument which triggered TAB completion is not completable.' );
		return '';
	}
	debug( 'Argument is completable.' );

	// Split the path to complete into two components: subdirectory path and filter...
	subdir = path.match( pathRegExp() );
	filter = subdir[ 2 ];
	subdir = subdir[ 1 ] || '';

	debug( 'Searching for completion candidates...' );
	if ( isRelativePath( path ) ) {
		debug( 'Detected a relative path. Resolving from the current working directory...' );
		dir = resolve( cwd(), subdir );
		debug( 'Resolved directory: %s', dir );
	} else {
		dir = subdir;
	}
	debug( 'Reading directory contents...' );
	files = readDir( dir );
	if ( files instanceof Error ) {
		debug( 'Unable to read directory: %s. Error: %s', dir, files.message );
		return '';
	}
	for ( i = 0; i < files.length; i++ ) {
		f = files[ i ];
		if ( !startsWith( f, filter ) ) {
			debug( '%s does not match filter %s. Skipping...', f, filter );
			continue;
		}
		f = resolve( dir, f );
		debug( 'Examining path: %s', f );
		try {
			stats = statSync( f );
			if ( stats.isDirectory() ) {
				debug( 'Path resolves to a subdirectory.' );
				out.push( files[ i ] + '/' );
				debug( 'Found a completion: %s', out[ out.length-1 ] );
			} else if ( stats.isFile() ) {
				debug( 'Path resolves to a file.' );
				out.push( files[ i ] );
				debug( 'Found a completion: %s', out[ out.length-1 ] );
			} else {
				debug( 'Path resolves to neither a directory nor a file. Skipping path...' );
				continue;
			}
		} catch ( err ) {
			debug( 'Error: %s', err.message );
			debug( 'Skipping path...' );
			continue;
		}
	}
	return filter;
}
Completes a file system API expression.

@private
@param {Array} out - output array for storing completions
@param {string} expression - expression to complete
@param {string} alias - file system API alias
@param {string} path - path to complete
@returns {string} path filter