ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What you posted is pretty much meaningless to me. I can't follow what you're saying at all. I doubt you're going to get any real help unless you show us some actual code, some real input values, and some background information on what the script is supposed to be doing vs. what it's actually doing.
And please use [code][/code] tags around your code, to preserve formatting and to improve readability.
Well my first question back would be, what does -l do? I searched through 2 man pages for ksh and could find only one
reference which was to switch uppercase letters to lower (not sure I could see the point here) so I figure it must
be something else you are trying to do?
Next, you say you are passing in an array and yet you say that x="a b" which is a string with a space in it?
Next, assuming that you store the value x in myLvalue, then you would at least need to do an indirect call to see what is stored in x.
Finally, You say you wish to loop over an array and yet you refer to your variable as a common variable, ie not of the format ${myLvalue[@]} ... or similar, so how is this looping over an array?
I bet the threat is dead and I'm actually replying to some advertisers now :-) But the issue posted by the OP made me post, really!
One of the problems with calling your script like this:
Code:
./test.ksh -l x ; where x="a b"
The part after the semicolon is not going to be parsed to your script; The semicolon is parsed by the shell first, and has the special meaning. Read up on that.
Your script indeed makes no sense to me, right now. I have no clue what you may want to accomplish and why you would want to do it this way... write a scripting language into a scripting language?
You could change things a bit around; assuming -l is the parameter for "array name", you could use -w for your "where" clause:
Code:
./test.ksh -l x -w x="a b"
With getopts you can parse your parameters and their values; but why you'd explicitly want to have your variable name in a variable itself is beyond me...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.