RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1254837 - typo in /etc/profile.d/less.sh
Summary: typo in /etc/profile.d/less.sh
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: less
Version: 6.7
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Pavel Raiskup
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On:
Blocks: 1269194
TreeView+ depends on / blocked
 
Reported: 2015-08-19 01:54 UTC by Frank Hirtz
Modified: 2019-11-14 06:53 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-09 05:20:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch for less.sh for Fedora Rawhide (351 bytes, patch)
2015-09-03 11:00 UTC, Ömer Fadıl Usta
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 615303 0 low CLOSED less fails to decompress empty files that have been gzipped 2021-02-22 00:41:40 UTC

Description Frank Hirtz 2015-08-19 01:54:58 UTC
What problem/issue/behavior are you having trouble with?  What do you expect to see?

Observed behaviour with a non-redhat "less", on RHEL6.7 (less-436-13.el6.x86_64):

$ less testfile >/dev/null
/bin/ksh: syntax error at line 1: `|' unexpected

This is due to the following change made to /etc/profile.d/less.sh:

<snip>
@@ -1,2 +1,2 @@
 # less initialization script (sh)
-[ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="|/usr/bin/lesspipe.sh %s"
+[ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="${LESSOPEN-||/usr/bin/lesspipe.sh %s}"
</snip>

The double '||' is an error / a typo, it needs to be a single '|' character there.

I can't say why it doesn't appear to affect the current stock "less" binary for RHEL5/RHEL6/RHEL7, but it does affect pretty much all others (try the RHEL5 'less' on RHEL6, to reproduce the error). Even an older RHEL6 less binary (from RHEL6.2) produces the error.

Steps to Reproduce:

1) Confirm current version:
[fmhirtz@ivanova bin]$ rpm -q less
less-436-13.el6_6.sjis.1.x86_64

2) Grab older version and get 'less' binary to test:

[fmhirtz@ivanova less]$ rpm2cpio ../less-436-4.el6.sjis.1.x86_64.rpm > less.cpio
[fmhirtz@ivanova less]$ cpio -i --make-directories < less.cpio 
397 blocks
[fmhirtz@ivanova less]$ cd usr/bin/
[fmhirtz@ivanova bin]$ ls
less  lessecho  lesskey  lesspipe.sh

3) Test older binary:
[fmhirtz@ivanova bin]$ ./less lesspipe.sh 
/bin/bash: -c: line 0: syntax error near unexpected token `|'
/bin/bash: -c: line 0: `|/usr/bin/lesspipe.sh lesspipe.sh'

Actual results:

/bin/ksh: syntax error at line 1: `|' unexpected

Expected results:

No error.

Comment 1 Frank Hirtz 2015-08-19 02:03:31 UTC
This was apparently introduced specifically as a fix in:

https://rhn.redhat.com/errata/RHBA-2014-0755.html

<snip>
* Previously, the lesspipe script returned incorrect exit status codes. As a
consequence, the less utility failed to decompress empty files that had been
compressed with the gzip utility, and an unwanted message was displayed. With
this update, a pipe character ("|") has been added in front of the LESSOPEN
environment variable to enforce a new default behavior of lesspipe. For backward
compatibility, lesspipe has the same behavior if LESSOPEN remains unchanged. As
a result, the less utility now detects and displays empty files correctly.
(BZ#615303)
</snip>

...but as a side-effect, now this breaks any environment where there's more than one version of 'less' present.

Comment 2 Viktor Jancik 2015-09-02 12:58:46 UTC
The double '||' is not a bug. It modifies the way less handles exit statuses from LESSOPEN scripts. Specifically, it maintains the original behavior (prior a change) for backwards compatibility with older LESSOPEN scripts.

As the bug is reported against RHEL 6.7, I don't think we should modify this behavior, as many currently running RHEL 6.7 could be using old LESSOPEN scripts.

I did however make the change in F22 and up.

Comment 3 Ömer Fadıl Usta 2015-09-03 10:58:44 UTC
(In reply to Viktor Jancik from comment #2)
> 
> I did however make the change in F22 and up.

Nope after trying to fix bug in less.sh in Fedora Rawhide made another typo.
Now we need to apply following patch which i will upload here

Comment 4 Ömer Fadıl Usta 2015-09-03 11:00:41 UTC
Created attachment 1069748 [details]
Patch for less.sh for Fedora Rawhide

This is fixing the """ /etc/profile.d/less.sh:[:2: too many arguments
  """ bug

Comment 5 Viktor Jancik 2015-09-03 11:25:47 UTC
Yes, I fixed that yesterday as the first report appeared. Sorry for the typo.

Comment 6 Ömer Fadıl Usta 2015-11-04 22:35:29 UTC
Is this bug still exist ?

Comment 7 Frank Hirtz 2016-01-04 15:14:56 UTC
The upstream fix works fine (tested on F23), is this something that'd be possible to change in RHEL? I know that there were concerns with behavioral changes in the area previously.

Comment 15 Pavel Raiskup 2016-04-25 04:46:49 UTC
The '||' syntax is used intentionally.  The $LESSOPEN variable points to
script which might exit with non-zero exit status -- and using the '||'
syntax guarantees that less will react on the status correctly.

If there is installed non-default 'less' program reacting on the same
configuration (environment variable) - the non-default 'less' program should
be updated to newer version >= v451.

If it is somehow important to run older less program, feel free to install
additional profile.d script which will set the LESSOPEN variable
unconditionally, or use the '~/.bash_profile' or equivalent shell init script.

Comment 16 Fedora Update System 2016-04-25 05:06:51 UTC
less-481-5.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-9a937faae1

Comment 17 Fedora Update System 2016-04-25 06:07:18 UTC
less-481-5.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-ff70f6b6a3

Comment 18 Fedora Update System 2016-04-25 17:50:59 UTC
less-481-5.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-9a937faae1

Comment 19 Fedora Update System 2016-04-26 00:52:43 UTC
less-481-5.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-ff70f6b6a3

Comment 20 Fedora Update System 2016-04-26 20:53:11 UTC
less-481-5.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 21 Fedora Update System 2016-05-07 11:55:28 UTC
less-481-5.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.


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