Solved

array arguments in ksh

Posted on 2004-10-27
2,023 Views
Last Modified: 2013-12-26
I'm writing a general function to process an array of strings, and I want that function to be able to receive the array as an argument.  Simple enough, right?  Well, given the following:

###########
function testit {
  echo $1 $2 $3
}

a[0]="hello world"
a[1]=goodbye

testit ${a[*]}
###########

this outputs:
hello world goodbye

Is there a way to pass in the *actual* array, and not the array elements joined by spaces?  I want to be able to recreate the array in the function, but the korn shell is a bit limited here...unless I'm missing something??

Thanks...
0
Question by:simulant
    1 Comment
     
    LVL 51

    Accepted Solution

    by:
    > Is there a way to pass in the *actual* array, and not the array elements joined by spaces?
    AFAIK not with ksh

    >  I want to be able to recreate the array in the function,
    the array has to be a global variable
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now