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 1317302 - ksh -n does not detect incorrect associative array declaration
Summary: ksh -n does not detect incorrect associative array declaration
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ksh
Version: 7.2
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks: 1298243 1420851
TreeView+ depends on / blocked
 
Reported: 2016-03-13 22:34 UTC by Paul Wayper
Modified: 2019-11-14 07:35 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-11 14:23:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Paul Wayper 2016-03-13 22:34:28 UTC
Description of problem:

ksh has the -n option to do a syntax test of the script and not actually execute it.  This test does not detect and warn on incorrect associative array declaration, whereas execution of the script breaks at that point.

Version-Release number of selected component (if applicable):

93u+ 2012-08-01

How reproducible:

Always

Steps to Reproduce:
1. Create the following scripts:
$ cat ksh_array.ksh 
#!/usr/bin/ksh

typeset -A fn
fn=([foo_key]=foo_val [bar_key]=bar_val)

printf %s\\n ${fn[foo_key]} ${fn[bar_key]}

$ cat ksh_bad_array.ksh 
#!/usr/bin/ksh

typeset -A fn
fn=([foo_key]=foo_val [bar_key])

printf %s\\n ${fn[foo_key]}

$ cat zsh_array.zsh 
#!/usr/bin/zsh

typeset -A fn
fn=(foo_key foo_val bar_key bar_val)

printf %s\\n ${fn[foo_key]} ${fn[bar_key]}

2. Test:
ksh -n ksh_array.ksh && echo result = $?
ksh ksh_array.ksh

3. Test:
ksh -n ksh_bad_array.ksh && echo result = $?
ksh ksh_bad_array.ksh

4. Test:
ksh -n zsh_array.zsh && echo result = $?
ksh zsh_array.zsh

Actual results:

2. Test passes and execution passes:
$ ksh -n ksh_array.ksh && echo result = $?
result = 0
$ ksh ksh_array.ksh
foo_val
bar_val

3. Test passes but execution fails:
$ ksh -n ksh_bad_array.ksh && echo result = $?
result = 0
$ ksh ksh_bad_array.ksh
ksh_bad_array.ksh[4]: [bar_key]: not found [No such file or directory]

4. Test passes but execution fails:
$ ksh -n zsh_array.zsh && echo result = $?
result = 0
$ ksh zsh_array.zsh
zsh_array.zsh: line 4: cannot append index array to associative array fn

Expected results:

2. Test passes and execution passes:
$ ksh -n ksh_array.ksh && echo result = $?
result = 0
$ ksh ksh_array.ksh
foo_val
bar_val

3. Test fails and execution fails:
$ ksh -n ksh_bad_array.ksh && echo result = $?
ksh_bad_array.ksh[4]: [bar_key]: not found [No such file or directory]
result = 1
$ ksh ksh_bad_array.ksh
ksh_bad_array.ksh[4]: [bar_key]: not found [No such file or directory]

4. Test fails and execution fails:
$ ksh -n zsh_array.zsh && echo result = $?
zsh_array.zsh: line 4: cannot append index array to associative array fn
result = 1
$ ksh zsh_array.zsh
zsh_array.zsh: line 4: cannot append index array to associative array fn


Additional info:

As zsh is designed to be mostly identical to ksh in execution but has a different associative array declaration syntax, ksh -n should work as a test of whether we are trying to execute a ksh or zsh shell script.

Comment 3 Siteshwar Vashisht 2017-07-11 14:23:10 UTC
I will move this bug upstream and close it as wontfix in RHEL7.

Comment 4 Siteshwar Vashisht 2017-07-11 17:30:21 UTC
https://github.com/att/ast/issues/55


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