karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan Foster (JIRA)" <j...@apache.org>
Subject [jira] [Created] (KARAF-2301) Improve shell syntax documentation
Date Sat, 04 May 2013 15:26:15 GMT
Alan Foster created KARAF-2301:
----------------------------------

             Summary: Improve shell syntax documentation
                 Key: KARAF-2301
                 URL: https://issues.apache.org/jira/browse/KARAF-2301
             Project: Karaf
          Issue Type: Improvement
            Reporter: Alan Foster


It would be nice if there were more examples within the karaf documentation for using the
shell language.

This documentation should be available within the 'help' command too if possible

For instance, there is currently no example of how the 'each' command works.

{code}
karaf@root> list = [1 2 3]; each ($list) { echo $it }
1
2
3
{code}

There is no mention of whether there support for returning/breaking early in the each command
either. After checking the source it doesn't appear to be possible, but it would be nice to
mention such a thing.

It would also be nice to show that the '[]' notation used will actually create an instance
of java ArrayList, and as such you can perform 'get' on it to access values

{code}
karaf@root> list = ["Hello" world]; echo ($list get 0) ($list get 1)
Hello world
{code}

And that you can actually see the class implementation details with '[] class'

It would be nice to show if there is a way to access primitive array types too. And if this
isn't possible, it might be nice to add that information

{code}
karaf@root> ("hello world" toCharArray)[0]
Error executing command: [C cannot be cast to [Ljava.lang.Object;
{code}

It would nice to stress the importance of spaces in the shell language too, as I imagine that
would be a very common gotcha

ie happy path if statement working as expected

{code:title=script.txt}
foo = "foo"
if { $foo equals "foo" } {
  echo "True!"
}
{code}

{code}
karaf@root> shell:source script.txt
True!
{code}

But without a space between the 'if' ie {code}if{ $foo equals "foo" } {'{code}

Then you get the following error, and it's very hard to tell what has gone wrong
{code}
karaf@root> shell:source script.txt
Error executing command: Cannot coerce echo "true!"() to any of []
{code}

I am happy to help with this documentation update, as I've currently got a small amount of
knowledge on the subject

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message