delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/23/14:05:36

X-Spam-Check-By: sourceware.org
Date: Tue, 23 May 2006 14:02:20 -0400 (EDT)
From: Igor Peshansky <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: bob <robert DOT lambert AT ae DOT ge DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: export arrays in cygwin ksh
In-Reply-To: <loom.20060523T184442-38@post.gmane.org>
Message-ID: <Pine.GSO.4.63.0605231335490.16854@access1.cims.nyu.edu>
References: <loom DOT 20060523T184442-38 AT post DOT gmane DOT org>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Tue, 23 May 2006, bob wrote:

> > Two comments.
> >
> > One: the output above didn't come from PDKsh in Cygwin (and, most
> > likely, didn't even come from the script you posted, since the export
> > statement is on line 9 in your script).  FYI, there is more than one
> > ksh implementation in Cygwin, and you'll need to tell us more about
> > your Cygwin installation (by following the Cygwin problem reporting
> > guidelines at <http://cygwin.com/problems.html>, especially the bit on
> > *attaching* the output of "cygcheck -svr").
> >
> > Two: PDKsh doesn't understand the "export a[*]" syntax.  It does
> > understand the "export a[1]" syntax, and even adds the array elements
> > to the export table, but there *is* a bug in it that doesn't actually
> > propagate the exported array elements to subshells.  I'll look into it
> > once I find the time.
> >
> > Igor Peshansky, volunteer PDKsh maintainer for Cygwin
>
> Igor
>
> Thanks much for responding.  My responses to your comments:
>
> Your right on the output... I cut out the stuff I tried but did not work
> in the program for clarity.

Would be nice to have the complete testcase, including the output...  Not
that the "export a[*]" syntax would work in it in any case...

> And 2 your are also right that it did not come from PDKsh.... I actually
> tried to envoke PDKsh by putting #!/bin/PDKsh on line 1 of test1 and
> test2 but all I got was an error msg (: bad interpreter: No such file or
> directory).

The filenames may be case sensitive, too -- the executable is called
"pdksh.exe", not "PDKsh.exe".  However, if you had followed the Cygwin
problem reporting guidelines at <http://cygwin.com/problems.html>, we
would have known what packages you have installed on your system.

> I have come to realize that there is more than 1 implementation of ksh.
> The syntax I used in my example is exactly what I use on my hp unix
> workstation and it works fine on the hp.  I did try to export individual
> elements like you suggest with no luck.

What does "ksh -c 'echo $KSH_VERSION'" print on your hpux workstation?
How about on Cygwin?  What is the output of "ls -l /bin/ksh.exe"?

> I did find in my installation in the cygwin/bin dir a file ksh.exe which
> is what I assume it was running.  Guess that is not pdksh.

PDKsh installs a /bin/ksh symlink if none is present.  So it could be
pdksh.  Please follow the above directions so that we can find out.

> My own IT people do not know what version of cygwin I am using (I am not
> laughing!)  I will try to find out more info on this.  I think we are
> using redhat, but will dig deeper.  Thanks

Please read and follow the Cygwin problem reporting guidelines at
<http://cygwin.com/problems.html>.  That will tell us the version of
Cygwin and various packages in your installation.

> Your last comment - are you saying I may not be able to export my array
> data to later processes or script files ?

You may try the other ksh packages in Cygwin, and see if they address your
problem.  Otherwise, the portable solution would be something like

# In the parent script
for i_ in `seq 0 ${#vname[*]}`; do vname_="$vname_ '${vname[$i_]}'"; done

# In the child script
eval "set -A vname $vname_"

A variant of this solution will also allow "exporting" arrays in bash.
HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019