Bug 743564 - ksh fails to process alias (echo='echo -e')
Summary: ksh fails to process alias (echo='echo -e')
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-10-05 11:48 UTC by Nikhil AR
Modified: 2018-11-14 10:27 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-11-07 12:30:50 UTC
Target Upstream Version:


Attachments (Terms of Use)

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


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