Am trying to run BaseX form the command shell to execute a xquery on a specific database. I'm however a bit confused by the -i command line option.

If I start BaseX as follows:
java -Xmx512m -cp "/Users/pascal/git/dwb/lib/BaseX77.jar" -Dorg.basex.DBPATH=../BaseXdata org.basex.BaseX -ifoo
which is expected to open the foo database, and from the prompt try to run:
> xquery count(*)
This returns a count of 0
However, if I type
> info database
I get the proper output about the current database (vs "No database opened" if none was selected).

If I then
> open foo
and
> xquery count(*)
I get the proper count of documents

Why do I have to count open again is the database is already 'opened'

Likewise these return a count of 0
java -Xmx512m -cp "/Users/pascal/git/dwb/lib/BaseX77.jar" -Dorg.basex.DBPATH=../BaseXdata org.basex.BaseX -ifoo "count(*)"
or
java -Xmx512m -cp "/Users/pascal/git/dwb/lib/BaseX77.jar" -Dorg.basex.DBPATH=../BaseXdata org.basex.BaseX -ifoo countscript.bx
though I would expect foo to be opened and ready for querying.

Any suggestion would be appreciated.

best
*P