Bug 743564

Summary: ksh fails to process alias (echo='echo -e')
Product: Red Hat Enterprise Linux 6 Reporter: Nikhil AR <nalayil>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED NOTABUG QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: mfranc, nalayil, prc, rpiddapa
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-07 12:30:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nikhil AR 2011-10-05 11:48:06 UTC
Description of problem:
ksh fails to process alias (echo='echo -e') in ksh-20100621-6.el6.x86_64


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


How reproducible:
Always


Steps to Reproduce: ksh kshTest.ksh

****************************************************
# cat kshTest.ksh 

#!/bin/ksh

. kshTestI.ksh

typeset -ft hugo

hugo "Install Apache Xerces (C++/Perl)" 

echo "\n\n Hello My dear Friend \n"

**************************************************
# cat kshTestI.ksh

#!/bin/ksh

alias echo='echo -e'

hugo() {
  alias echo
  echo "\n\n  ==== ${0##*/}: $1 ====\n" 
}

*************************************************
Actual results:

echo='echo -e'
\n\n  ==== kshTest.ksh: Install Apache Xerces (C++/Perl) ====\n


 Hello My dear Friend 


Expected results:

echo='echo -e'


 ==== kshTest.ksh: Install Apache Xerces (C++/Perl) ====



 Hello My dear Friend 

Additional info:

Issue is always reproducible in f15 ksh(ksh-20110630-3.fc15.x86_64) as well.

Customer says, the same works successfully in OpenSuSE 11.4 ksh(ksh-93t-176.2.x86_64). I think the sneaky guys at SuSE didn't pulled the patch upstream.

Comment 2 Michal Hlavinka 2011-11-04 12:30:02 UTC
This is how it's designed to work.

man page:

aliases: Aliasing is performed when scripts are read, not while they are executed. Therefore, for an alias to take effect, the alias definition command has to be executed before the command which references the alias is read.

. name: Otherwise if name refers to a file, the file is read in its entirety and the commands are executed in the current shell environment.


And confirmed from upstream:
=========================================================
this is documented behavior.  aliases are expanded when reading
a script and a dot script is read in its entirety before running
any commands.  Therefore, any aliases defined in a . script (or function)
will not take effect for that dot script or function.

However, profile files are read an processed one command at a time unlike
dot scripts.
=========================================================

so this is a wontfix