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.


In reply to Term::ReadLine::readline patch by converter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.