Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-3264

What is the AND operator in shell:if ?

    Details

    • Type: Question
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.7
    • Fix Version/s: 4.0.0.M2, 4.0.0.M3
    • Component/s: karaf
    • Labels:
      None

      Description

      I have tried to create an shell:if condition that tests for multiple AND / OR operators but I am unable to find any useful documentation in KARAF or FELIX nor did anyone respond to user forum emails or was there any hint in unit tests as to how to construct a if condition with multiple operants.

      Using the debugger, I can see in org.apache.felix.gogo.runtime.Closure that there is something amiss when executing my code but I tried quite a few permutations without any luck.

      Example of what I thought the most likely syntax it should be but fail, fail, fail ... any chance someone with some scripting credentials is able to comment? I am offering to write it up with a few examples for the developer documentation!

      foo = "foo"
      bar = "bar"
      if { &($foo equals "foo")($bar equals "bar") } { echo "yes foo and bar" } { echo "no foo and bar" }
      

      another one I tried:

      foo = "foo"
      bar = "bar"
      if { $foo equals "foo" && $bar equals "bar" } { echo "yes foo and bar" } { echo "no foo and bar" }
      

      or this one:

      foo = "foo"
      bar = "bar"
      if { [ $foo equals "foo" , $bar equals "bar" ] } { echo "yes foo and bar" } { echo "no foo and bar" }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gnt Guillaume Nodet
                Reporter:
                niels.bertram Niels Bertram
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: