Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single and double quotes not interchangeable after xst execute #116

Open
daliboris opened this issue May 1, 2023 · 8 comments
Open

Single and double quotes not interchangeable after xst execute #116

daliboris opened this issue May 1, 2023 · 8 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@daliboris
Copy link

What happened?

When calling execute command with parameter that expect string, only combination of single quotes inside double quoted text ("... '..' ... " ) works.

The opposit case ('... ".." ... ') doesn't work: double quotes are ommited.

Combination of single quotes inside double quotes is used in the readme help.

System Information

Build: eXist-6.0.1 (51506fc97a9e5bb55fdea71fc76def2c9d402886)
Java: 1.8.0_292 (Azul Systems, Inc.)
OS: Windows 10 10.0 (amd64)

Relevant shell output

xst execute 'xmldb:reindex("/db/apps/%project%-data")' --config admin.xstrc
xmldb:reindex(/db/apps/mordigital-data)

xst execute "xmldb:reindex('/db/apps/%project%-data')" --config admin.xstrc
true
@daliboris daliboris added the bug Something isn't working label May 1, 2023
@daliboris daliboris changed the title Single and double quotes not interchangeable in xst execute Single and double quotes not interchangeable after xst execute May 1, 2023
@line-o
Copy link
Member

line-o commented May 5, 2023

@daliboris looks like a windows issue to me. On linux double quoted strings will be subject to variable replacement.

xst run "$a + $a" -b '{"a": 1}' will not work on unix/linux/macOS shells as "$a" is replaced before xst gets to see it.

@line-o
Copy link
Member

line-o commented May 5, 2023

@daliboris Which shell are you using?

@line-o
Copy link
Member

line-o commented May 5, 2023

What happens on windows with the following?

xst execute 'xmldb:reindex("/db/apps/" || $project || "-data")' --bind '{ "project": "mordigital" }' --config admin.xstrc

@line-o
Copy link
Member

line-o commented May 5, 2023

There seems to be a lot to take into account when it comes to double quotes on windows (see
https://stackoverflow.com/questions/562038/escaping-double-quotes-in-batch-script)

@daliboris
Copy link
Author

Which shell are you using?

I'm using cmd.exe shell.

In PowerShell 5.1, the error (for xst execute 'xmldb:reindex("/db/apps/mordigital-data/data/dictionaries")' --config admin.xstrc) looks more sophisticated:

XPathException:
err:XPTY0004 checking function parameter 1 in call xmldb:reindex(untyped-value-check[xs:string, [root-node]/child::{}db/child::{}apps/child::{}mordigital-data/child::{}data/child::{}dictionaries]): XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: xmldb:reindex($collection-uri as xs:string) xs:boolean. Expected cardinality: exactly one, got 0. [at line 1, column 1, source: String/7292787417532134543]

Running xst run "$a + $a" -b '{"a": 1}' also fails in CMD and PowerShell:

xst run "$a + $a" -b '{"a": 1}'
Problem with a provided Argument:
Error parsing argument bind! Reason: Unexpected token ' in JSON at position 0

What happens on windows with the following?

xst execute 'xmldb:reindex("/db/apps/" || $project || "-data")' --bind '{ "project": "mordigital" }' --config admin.xstrc
Error executing your query
Failed to invoke method executeQuery in class org.exist.xmlrpc.RpcConnection: org.exist.xquery.StaticXQueryException: exerr:ERROR expecting ''', found '/' [at line 1, column 24]
'$project' is not recognized as an internal or external command,
operable program or batch file.
'"-data")'' is not recognized as an internal or external command,
operable program or batch file.

@line-o
Copy link
Member

line-o commented Oct 7, 2023

OK, so the readme should point out which combination of quotes works on Linux and windows.

@line-o line-o added documentation Improvements or additions to documentation and removed bug Something isn't working labels Oct 7, 2023
@line-o
Copy link
Member

line-o commented Nov 18, 2023

@daliboris does this command work on windows?

xst execute "xmldb:reindex('/db/apps/' || $project || '-data')" --bind "{ \"project\": \"mordigital\" }" --config admin.xstrc

@daliboris
Copy link
Author

Hi @line-o , here are some results (I changed the project name):

CMD

xst execute "xmldb:reindex('/db/apps/' || $project || '-data')" --bind "{ \"project\": \"lediir\" }" --config admin.xstrc
true

PowerShell

xst execute "xmldb:reindex('/db/apps/' || $project || '-data')" --bind "{ \"project\": \"lediir\" }" --config admin.xstrc
Problem with a provided Argument:
Error parsing argument bind! Reason: Unexpected token : in JSON at position 12

--bind '{ "project": "lediir" }'

xst execute "xmldb:reindex('/db/apps/' || $project || '-data')" --bind '{ \"project\": \"lediir\" }' --config admin.xstrc
XPathException:
err:XPST0003 unexpected token: || [at line 1, column 31]

--bind "{ 'project': 'lediir' }"

xst execute "xmldb:reindex('/db/apps/' || $project || '-data')" --bind "{ \'project\': \'lediir\' }" --config admin.xstrc
Problem with a provided Argument:
Error parsing argument bind! Reason: Unexpected token \ in JSON at position 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants