Bug 20097 - ksh bug in script
ksh bug in script
Status: CLOSED DUPLICATE of bug 8894
Product: Red Hat Linux
Classification: Retired
Component: pdksh (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Trond Eivind Glomsrxd
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-10-31 09:22 EST by Need Real Name
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-10-31 09:22:22 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2000-10-31 09:22:19 EST
Simply try the following script:
--------------
#!/bin/ksh
typeset a=1
function x {
a=7
}
echo "a) $a"
x | read line
echo "b) $a"
x
echo "c) $a"
--------------
The result is
a) 1
b) 1
c) 7

while I expected
a) 1
b) 7
c) 7

Also according to the manual page of the ksh:
       Compound commands are created using the following reserved
       words  --  these	 words	are  only  recognized if they are
       unquoted and if they are used as the first word of a  com-
       mand  (i.e.,  they  can't be preceded by parameter assign-
       ments or redirections):
		  case	 else	function   then	   !
		  do	 esac	if	   time	   [[
		  done	 fi	in	   until   {
		  elif	 for	select	   while   }
       Note: Some shells  (but	not  this  one)	 execute  control
       structure commands in a subshell when one or more of their
       file  descriptors  are  redirected,  so	any   environment
       changes	inside	them  may fail.	 To be portable, the exec
       statement should be used instead to redirect file descrip-
       tors before the control structure.
Comment 1 Trond Eivind Glomsrxd 2000-10-31 12:52:43 EST

*** This bug has been marked as a duplicate of 8894 ***

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