From: Richard Jones Date: Tue, 25 May 2010 12:54:11 +0000 (+0100) Subject: fish: Don't eat words when completing case-insensitive paths (RHBZ#582993). X-Git-Tag: 1.3.15~3 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=21bd2db7cf259a17cc3922409937b849e4b83c0f;hp=53c3b9d2b03fa5cb0ac7e86a5a51f2a18a2b91c1 fish: Don't eat words when completing case-insensitive paths (RHBZ#582993). --- diff --git a/fish/destpaths.c b/fish/destpaths.c index 403fe7f..5ed93ec 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -230,7 +230,20 @@ complete_dest_paths_generator (const char *text, int state) word = &words[index]; index++; - if (STRCASEEQLEN (word->name, text, len)) { + /* Whether we should match case insensitively here or not is + * determined by the value of the completion-ignore-case readline + * variable. Default to case insensitive. (See: RHBZ#582993). + */ + char *cic_var = rl_variable_value ("completion-ignore-case"); + int cic = 1; + if (cic_var && STREQ (cic_var, "off")) + cic = 0; + + int matches = + cic ? STRCASEEQLEN (word->name, text, len) + : STREQLEN (word->name, text, len); + + if (matches) { if (word->is_dir) rl_completion_append_character = '/'; diff --git a/fish/fish.c b/fish/fish.c index cbbbf97..557a6ac 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -1417,6 +1417,13 @@ initialize_readline (void) rl_readline_name = "guestfish"; rl_attempted_completion_function = do_completion; + + /* Note that .inputrc (or /etc/inputrc) is not read until the first + * call the readline(), which happens later. Therefore, these + * provide default values which can be overridden by the user if + * they wish. + */ + (void) rl_variable_bind ("completion-ignore-case", "on"); #endif } diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 803f35a..5737c46 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -904,6 +904,22 @@ To write rules which only apply to guestfish, use: ... $endif +Variables that you can set in inputrc that change the behaviour +of guestfish in useful ways include: + +=over 4 + +=item completion-ignore-case (default: on) + +By default, guestfish will ignore case when tab-completing +paths on the disk. Use: + + set completion-ignore-case off + +to make guestfish case sensitive. + +=back + =item test1.img =item test2.img (etc)