Re: Multiple variable assignments in ksh

From: Janis Papanagnou (Janis_Papanagnou_at_hotmail.com)
Date: 03/24/05


Date: Thu, 24 Mar 2005 20:05:27 +0100

Dan wrote:
> Is there a way to do multiple variable assignments in ksh on a single
> line? Something like this:
>
> #!/bin/ksh
> (Var1,Var2)=($1,$2)
> echo "Values:\n\t${Var1}\n\t${Var2}\n"
>
> Not a big deal, just wondering.

No that's not possible. The closest is the "compound assignment"

   v=( var1=$1 var2=$2 )

where you can access the variables as components of a structure

   print - ${v.var1} ${v.var2}

Though ordering is important in this assignment; it's sequential.

Janis



Relevant Pages

  • Re: Multiple variable assignments in ksh
    ... On Thu, 24 Mar 2005 at 15:41 GMT, Dan wrote: ... > Is there a way to do multiple variable assignments in ksh on a single ... My code in this post is copyright 2005, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License ...
    (comp.unix.shell)
  • Re: Another Database SQL Update question
    ... I go with Dan here. ... <_tally value generating statement> ... The assignment is before anything else, ... This problem is reminescent of the parametersfunction which ...
    (microsoft.public.fox.programmer.exchange)
  • Re: [C, C++] "(a=b) = c;" Illegal or Undefined?
    ... Dan himself was only made aware of recently WRT this issue. ... Assignment operators are concerned with the _address_ of their left ... conclude its work before another processor completes evaluation of the ... evaluations (if it left the complex expressions for last, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: modifing a path (string)
    ... The initial assignment ... This should work with ksh, dtksh, and bash. ...
    (comp.unix.shell)