New extension: Filename Completion (Shell)

Hey everyone!

The next extension for the Shell challenge is now live: Filename Completion.

Filename Completion allows your shell to complete file and directory names when the user presses TAB.

Once you complete this extension, your shell will support behaviors like:

$ cat READ<TAB>
$ cat README.md

Here’s the stage breakdown:

Please give this a try and let us know how it can be improved! @UdeshyaDhungana (author of this extension) and I will be available here to help out with any tester or instruction-related issues.

1 Like

Frankly, I don’t get this extension. I mean, yeah, if you implement completion without readline, this is interesting. But the earlier stages strongly suggest using readline, so I passed all tests in this extension without changing a line.

@user-0xcafe what language and what readline library are you using? While testing this we had to implement functionality on our own, but I just read about rl_filename_completion_function right now – we hadn’t seen this before. Did you have to enable anything at all or did it just work out of the box?

@rohitpaulk OK, I did some research. For context: I am using C++ with GNU Readline and didn’t have to change a thing to pass all tests.

As it turns out, I am using rl_attempted_completion_function and not setting rl_completion_entry_function. If rl_completion_entry_function is null, GNU Readline will automatically fall back to the built in filename completion. I didn’t even consider to use rl_completion_entry_function since I wanted to get filename completion for free :slight_smile: Source: GNU Readline Library

1 Like