Need to understand what this for loop will do?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjuks
    New Member
    • Dec 2007
    • 72

    Need to understand what this for loop will do?

    HI All,

    Can any one please let me know what this for loop is trying to do

    for V in ${MYVERSION[$I]:-"$VERSION"}

    what :- stands for? I dont understand this condition,
    Can any one help me please?

    Thanks
    Manjuks
  • chorny
    Recognized Expert New Member
    • Jan 2008
    • 80

    #2
    This code does not look like Perl

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      @chorny is right, its not Perl code. Its actually Bash shell scripting code.

      Here is an excerpt from the Bash man page:

      ${parameter:-word}
      Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

      Regards,

      Jeff

      Comment

      • manjuks
        New Member
        • Dec 2007
        • 72

        #4
        Hi thanks Jeff.
        It made me clear, In my case both MYVERSION[$I]and "$VERSION" are NULL. It means It should not go inside the for loop.

        But In Solaris KSH it was getting inside the for loop, and in Linux KSH it was not. Its because of KSH version mismatch.

        Thanks,
        Manjunath

        Comment

        Working...