Note that there are some explanatory texts on larger screens.

plurals
  1. POGNU readline whitespace quoting
    text
    copied!<p>i´m working on an application which uses readline to read commands from stdin. It accepts "cd", and other commands which require a path as an argument. I'm having troubles with paths that include whitespaces. My objective is to somehow make readline quote the whitespaces, and autocomplete the path name after this character appears(actually, when a space is encountered, it is just skipped, and autocompletion starts from the next word).</p> <p>I've been trying to achieve this, but i keep trying things and none of them work. I've managed to quote a " " into a "\ ", which is what i want. But then readline doesn't interpret this as part of the path, it just skips it, and autocompletes the next word as if there was nothing before that. Basically, i'm expecting the same behaviour as bash's autocompletion.</p> <p>Any help is appreciated. Thanks in advance!</p> <p>Edit:</p> <p>Alright, so i've managed to somehow accomplish what i was looking for. What i did was:</p> <p>During initialization: </p> <pre><code>rl_attempted_completion_function = completition; rl_completer_quote_characters = "\""; rl_filename_quote_characters = " "; </code></pre> <p>completition should return a char** containing every command that matches what "text" as so far. I've ommitted that part, since it doesn't have to do with what i was asking. The important part is the rl_filename_quoting_desired = 1; which tells readline that you want your filenames to be quoted. </p> <pre><code>char **completition(const char *text, int start, int end) { rl_filename_quoting_desired = 1; return 0; } </code></pre> <p>Note that what i ended up doing is what BuHHu-nyx said, just adding double quotes(") to filenames. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload