jovanbulck / jsh

A basic UNIX shell implementation in C
GNU General Public License v3.0
30 stars 10 forks source link

Autocompletion doesn't escape spaces #35

Open GijsTimmers opened 9 years ago

GijsTimmers commented 9 years ago

Expected behaviour:

$ pwd
  /mnt/Data
$ cd Muziek/Franki<TAB>
$ cd Muziek/Frankie Knuckles\ -\ Beyond\ The\ Mix/
$ pwd
  /mnt/Data/Muziek/Frankie Knuckles - Beyond The Mix/

Actual behaviour:

$ pwd
  /mnt/Data
$ cd Muziek/Franki<TAB>
$ cd Muziek/Frankie Knuckles - Beyond The Mix/        ## No escaping!
  [DEBUG: You entered: 'cd Muziek/Frankie Knuckles - Beyond The Mix/']
  [DEBUG: alias: input resolved to: 'cd Muziek/Frankie Knuckles - Beyond The Mix/']
  jsh: cd: wrong number of arguments    (expected = 1)
  [DEBUG: built-in: executed 'cd']
  [DEBUG: freeing comd struct for 'cd']
  [DEBUG: parseexpr: expr evaluated with return value 1]
  [DEBUG: readcmd: freeing memory for: 'cd']
$ pwd
  /mnt/Data
jovanbulck commented 9 years ago

I've been hacking on this yesterday. See this branch. After lots of trouble I managed to get something working, sort of... I looked into the source code of bash and copied some code of it, trying to understand the autocompletion API of readline, which really sucks. :/ I managed to get autocompletion escaping spaces working for single matches, but somehow it all breaks when multiple matches are found (restarts at the beginning).

Anyone who feels like working further on this --> go ahead! I guess we need some help on this (e.g. Stackoverflow) since I clearlly don't understand the API well enough...

In this branch you'll allo find a solution for the case insensitive completion, as discussed in issue #16 . At least something that's working :-)

jovanbulck commented 9 years ago

See issue #51 for further discussion