Bug 1397458 - nano regular expression searches [:lower:] and [:upper:] do not work
Summary: nano regular expression searches [:lower:] and [:upper:] do not work
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: nano
Version: 24
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Kamil Dudka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-22 15:11 UTC by Don Swaner
Modified: 2016-11-23 02:58 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-22 15:21:40 UTC
Type: Bug


Attachments (Terms of Use)

Description Don Swaner 2016-11-22 15:11:29 UTC
Description of problem:
In nano, searches for regular expressions are supported.  However, for character classes [:lower:], [:upper:] the results are incorrect.  This is while invoking nano with "env LC_CTYPE=C nano ...", or just with "nano ..."
(LC_CTYPE="en_US.utf8")

Version-Release number of selected component (if applicable):
nano-2.5.3-1.fc24.x86_64

How reproducible:
Always

Steps to Reproduce:
1.  Invoke nano with "env LC_ALL=C nano ..."
    (May want to use a file containing "0 a Z % . 1 b Y # , ✓" for testing)
    Note: last character in string is unicode check mark.
2.  Invoke a search (CTL-w), then switch to a regex search (ALT-r)
3.  For the regex, enter "[[:upper:]]" (no-quotes), and press enter

Actual results:
The search places the cursor on the next letter, lower case, or upper case, regardless.

Expected results:
The search places the cursor on the next upper case letter.

Additional info:
The following regex work as expected (incomplete list):
[[:digit:]]
[^[:digit:]]
[[:alpha:]]
[^[:alpha:]]
[[:print:]]
[^[:print:]]

The following regex do NOT work as expected (incomplete list):
[[:lower:]]
[[:upper:]]

Comment 1 Kamil Dudka 2016-11-22 15:21:40 UTC
You need to enable case-sensitive search by ALT-c to get the expected result.  Alternatively, you can can enable case-sensitive search by default:

echo set casesensitive >> ~/.nanorc

Comment 2 Don Swaner 2016-11-22 15:33:26 UTC
Thanks for the info.  While it is good that there are 2 alternative ways to do a case sensitive search that do work, the regular expression way should also work, or it should be documented that it does not work.

Comment 3 Kamil Dudka 2016-11-22 16:01:32 UTC
As I understand it, the Reg Exp and Case Sens options are independent of each other.  You can choose:

1) plain-text case-insensitive search
2) plain-text case-sensitive search
3) regex-based case-insensitive search
4) regex-based case-sensitive search

All the combinations seem to work as expected.  If you find it confusing, please report it directly to the upstream developers, preferably with a patch improving the current documentation.

Comment 4 Don Swaner 2016-11-22 16:41:35 UTC
Thanks for the clarification.  So the "regular expressions" in nano are actually Franken-sort-of-regular-expressions.  I'll work on some verbage for upstream.

Comment 5 Don Swaner 2016-11-23 02:58:40 UTC
The behavior of nano is the same as "grep -i" - so this is not a bug - and nano does not have Franken-regular-expressions - even if they are confusing sometimes.


Note You need to log in before you can comment on or make changes to this bug.