Term::ReadLine::readline (required by Term::ReadLine::Perl) has some problems parsing the GNU readline library's inputrc file (discussed here: cpan warnings).

This preliminary patch makes the processing of the 'on' and 'off' arguments to the `set' directive case-insensitive, and quiets the warnings about the unsupported `show-all-if-ambiguous' directive. It also allows trailing comments, which cause errors in the un-patched version.

The changes are trivial, but I'd like to give others the chance to test it before I submit to p5p for consideration.

Thank you, conv

--- readline.pm.orig Tue Oct 23 16:00:34 2001 +++ readline.pm Wed Oct 24 01:15:04 2001 @@ -393,6 +393,11 @@ $SIG{'WINCH'} = "readline::get_window_size"; } +# Fix: case-sensitivity of inputrc on/off keywords in +# `set' commands. readline lib doesn't care about case. +# changed case of keys 'On' and 'Off' to 'on' and 'off' +# &rl_set changed so that it converts the value to +# lower case before hash lookup. sub preinit { ## Set up the input and output handles @@ -401,8 +406,8 @@ $term_OUT = \*STDOUT unless defined $term_OUT; ## not yet supported... always on. $var_HorizontalScrollMode = 1; - $var_HorizontalScrollMode{'On'} = 1; - $var_HorizontalScrollMode{'Off'} = 0; + $var_HorizontalScrollMode{'on'} = 1; + $var_HorizontalScrollMode{'off'} = 0; $var_EditingMode{'emacs'} = *emacs_keymap; $var_EditingMode{'vi'} = *vi_keymap; @@ -410,44 +415,52 @@ $var_EditingMode{'vipos'} = *vipos_keymap; $var_EditingMode{'visearch'} = *visearch_keymap; + # get rid of warning from Mandrake Linux' /etc/inputrc: + # Undefined value assigned to typeglob at (eval 9) line 15. + # Warning [/etc/inputrc line 7]: + # Invalid variable `show-all-if-ambiguous' + $var_ShowAllIfAmbiguous = 1; + $var_ShowAllIfAmbiguous{'off'} = 0; + $var_ShowAllIfAmbiguous{'on'} = 1; + ## not yet supported... always on $var_InputMeta = 1; - $var_InputMeta{'Off'} = 0; - $var_InputMeta{'On'} = 1; + $var_InputMeta{'off'} = 0; + $var_InputMeta{'on'} = 1; ## not yet supported... always on $var_OutputMeta = 1; - $var_OutputMeta{'Off'} = 0; - $var_OutputMeta{'On'} = 1; + $var_OutputMeta{'off'} = 0; + $var_OutputMeta{'on'} = 1; ## not yet supported... always off $var_ConvertMeta = 0; - $var_ConvertMeta{'Off'} = 0; - $var_ConvertMeta{'On'} = 1; + $var_ConvertMeta{'off'} = 0; + $var_ConvertMeta{'on'} = 1; ## not yet supported... always off $var_MetaFlag = 0; - $var_MetaFlag{'Off'} = 0; - $var_MetaFlag{'On'} = 1; + $var_MetaFlag{'off'} = 0; + $var_MetaFlag{'on'} = 1; ## not yet supported... always off $var_MarkModifiedLines = 0; - $var_MarkModifiedLines{'Off'} = 0; - $var_MarkModifiedLines{'On'} = 1; + $var_MarkModifiedLines{'off'} = 0; + $var_MarkModifiedLines{'on'} = 1; ## not yet supported... always off $var_PreferVisibleBell = 0; - $var_PreferVisibleBell{'On'} = 1; - $var_PreferVisibleBell{'Off'} = 0; + $var_PreferVisibleBell{'on'} = 1; + $var_PreferVisibleBell{'off'} = 0; ## this is an addition. Very nice. $var_TcshCompleteMode = 0; - $var_TcshCompleteMode{'On'} = 1; - $var_TcshCompleteMode{'Off'} = 0; + $var_TcshCompleteMode{'on'} = 1; + $var_TcshCompleteMode{'off'} = 0; $var_CompleteAddsuffix = 1; - $var_CompleteAddsuffix{'On'} = 1; - $var_CompleteAddsuffix{'Off'} = 0; + $var_CompleteAddsuffix{'on'} = 1; + $var_CompleteAddsuffix{'off'} = 0; # To conform to interface $minlength = 1 unless defined $minlength; @@ -1268,11 +1281,14 @@ next; } elsif ($action[$#action] ne 'exec') { ## skipping this one.... - } elsif (m/\s*set\s+(\S+)\s+(\S*)\s*$/) { + # changed next three patterns: readline permits trailing comments + in inputrc + # this seems to solve the warnings caused by trailing comments in + the + # default /etc/inputrc on Mandrake Linux boxes. + } elsif (m/\s*set\s+(\S+)\s+(\S*)/) { &rl_set($1, $2, $file); - } elsif (m/^\s*(\S+):\s+("[^\"]*")\s*$/) { + } elsif (m/^\s*(\S+):\s+("[^\"]*")/) { &rl_bind($1, $2); - } elsif (m/^\s*(\S+):\s+(\S+)\s*$/) { + } elsif (m/^\s*(\S+):\s+(\S+)/) { &rl_bind($1, $2); } else { chop; @@ -1885,6 +1901,9 @@ sub rl_set { local($var, $val) = @_; + + # &preinit's keys are now all lower-case + $val = lc $val; $var = 'CompleteAddsuffix' if $var eq 'visible-stats';

Edit - Petruchio Sat Oct 27 10:31:23 UTC 2001: Added READMORE tag.

Replies are listed 'Best First'.
Re: Term::ReadLine::readline patch
by chromatic (Archbishop) on Oct 26, 2001 at 06:26 UTC
    This fixed several warnings on one of my boxes. Good job.

    Update: By "several", I mean "all of the warnings that could possibly be ascribed to Term::Readline::readline". You're not expected to fix warnings that I've caused. :)

      Thank you for the feedback.

      If by "several warnings" you mean "several but not all" please let me know what the remaining warnings are and I'll try to address them.