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 1222025 - unset arguments are not treated as an error when set -u is used
Summary: unset arguments are not treated as an error when set -u is used
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ksh
Version: 7.1
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: Jan Kepler
URL:
Whiteboard:
Depends On:
Blocks: 1298243
TreeView+ depends on / blocked
 
Reported: 2015-05-15 14:11 UTC by Marcel Kolaja
Modified: 2020-12-11 11:50 UTC (History)
9 users (show)

Fixed In Version: ksh-20120801-34.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1466395 (view as bug list)
Environment:
Last Closed: 2017-08-01 16:26:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer (30 bytes, application/x-shellscript)
2015-05-15 14:11 UTC, Marcel Kolaja
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Debian BTS 780957 0 None None None Never
Red Hat Knowledge Base (Solution) 2912901 0 None None None 2017-02-07 16:13:20 UTC
Red Hat Product Errata RHBA-2017:1936 0 normal SHIPPED_LIVE ksh bug fix update 2017-08-01 17:55:48 UTC

Description Marcel Kolaja 2015-05-15 14:11:04 UTC
Description of problem:
When set -u is used, ksh should treat unset parameters as an error when substituting. This does not work for unset positional parameters like $1. It does work, however, for usual variables (see the attached reproducer).

Version-Release number of selected component (if applicable):
20120801-22.el7_1.1

How reproducible:
always

Steps to Reproduce:
1. run the attached reproducer

Actual results:
No error printed for $1.

Expected results:
An error printed for $1

Additional info:
N/A

Comment 1 Marcel Kolaja 2015-05-15 14:11:43 UTC
Created attachment 1025897 [details]
reproducer

Comment 4 Michal Hlavinka 2015-05-17 20:51:52 UTC
This is intentional change made by upstream.
09-05-12  To conform with POSIX, the -u option only checks for unset variables
	  and subscript elements rather than checking for all parameters.

Comment 5 Karl Abbott 2015-05-19 11:53:51 UTC
Michal,

Had the customer ask the following:

"Your update is clear that upstream made this as a deliberate change to conform with POSIX.

Is the upstream position that this is not a bug/ regression and will not be fixed and that the previous behaviour will not be made available through an option/ environment variable?

Tim
"

I re-opened this so that you'll get the notification. I would like to have an answer to this as I think it's a really well thought out question.

Cheers,
Karl

Comment 6 Karl Abbott 2015-05-20 16:42:41 UTC
Michal,

Also:

"Hi Karl,

A point of interest:

Checking with our Solaris team they have a case open with Oracle for the same issue.

Oracle responded to our Solaris team today that they (Oracle Solaris engineering) have been working on a change which has been integrated into the upstream.

Tim"

Karl

Comment 11 Marcel Kolaja 2015-09-17 16:00:11 UTC
When the change in varsub() in macro.c mentioned in the following post is made, we get in the newly added part of the code, when $1 is being expanded:

http://lists.research.att.com/pipermail/ast-developers/2015q2/004038.html

Then strchr() seems to return a pointer to the terminator and errormsg() is not called.

Comment 19 Siteshwar Vashisht 2017-01-30 13:20:05 UTC
Upstream patch is slightly different from the submitted patch in comment 12, check for non-zero d is unnecessary :


https://github.com/att/ast/blob/beta/src/cmd/ksh93/sh/macro.c#L1230-L1236

if(!v && sh_isoption(mp->shp,SH_NOUNSET))
	{
         d=fcget();
         fcseek(-1);
         if(!strchr(":+-?=",d))
	     errormsg(SH_DICT,ERROR_exit(1),e_notset,ltos(c));
	}

Comment 20 Siteshwar Vashisht 2017-01-30 16:06:15 UTC
strchr() can search for NULL characters in string, so check for 0 is required. The patch in comment 12 looks good.

Comment 24 errata-xmlrpc 2017-08-01 16:26:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1936


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