Discussion:
Riot CMD: parsing invalid data returns exit code 0
Jindřich Mynarz
2016-06-20 17:17:38 UTC
Permalink
Hi,

parsing invalid data data with Riot command-line tool (
https://jena.apache.org/documentation/io/#command-line-tools) returns exit
code 0 (i.e. success) instead of an error exit code:

riot --validate invalid.ttl; echo $?
# => 0

Is that an intentional design choice?

My Riot version information:

riot --version
Jena: VERSION: 3.1.0
Jena: BUILD_DATE: 2016-05-10T11:59:39+0000
RIOT: VERSION: 3.1.0
RIOT: BUILD_DATE: 2016-05-10T11:59:39+0000

- Jindřich
--
Jindřich Mynarz
http://mynarz.net/#jindrich
Andy Seaborne
2016-06-20 19:54:37 UTC
Permalink
Post by Jindřich Mynarz
Hi,
parsing invalid data data with Riot command-line tool (
https://jena.apache.org/documentation/io/#command-line-tools) returns exit
riot --validate invalid.ttl; echo $?
# => 0
Is that an intentional design choice?
Not intentional.

The "--validate" is a command line tool for checking data and producing
a report. It does multiple files in one run.


But what errors/warnings do you get?

Andy
Post by Jindřich Mynarz
riot --version
Jena: VERSION: 3.1.0
Jena: BUILD_DATE: 2016-05-10T11:59:39+0000
RIOT: VERSION: 3.1.0
RIOT: BUILD_DATE: 2016-05-10T11:59:39+0000
- Jindřich
Jindřich Mynarz
2016-06-20 20:15:12 UTC
Permalink
The "--validate" is a command line tool for checking data and producing a
report. It does multiple files in one run.
OK, I see. Is there another way to run Riot command line tool so that it
produces an error exit status when provided with syntactically invalid
input?

But what errors/warnings do you get?


Just a regular (and correct) ERROR because of invalid syntax of my input.

- Jindřich
Andy Seaborne
2016-06-20 20:39:58 UTC
Permalink
Post by Jindřich Mynarz
The "--validate" is a command line tool for checking data and producing a
report. It does multiple files in one run.
OK, I see. Is there another way to run Riot command line tool so that it
produces an error exit status when provided with syntactically invalid
input?
Shell magic are be applied:

capture the output and test it.

If in a subshell, the exit here will set the out $?

-------------
#!/bin/bash

(
X="$(riot --validate ... 2&>1)"
if [[ -n "$X" ]]
then
exit 99
fi
)
echo $?
-------------
Post by Jindřich Mynarz
But what errors/warnings do you get?
Just a regular (and correct) ERROR because of invalid syntax of my input.
- Jindřich
Jindřich Mynarz
2016-06-20 21:06:55 UTC
Permalink
Post by Andy Seaborne
capture the output and test it.
If in a subshell, the exit here will set the out $?
-------------
#!/bin/bash
(
X="$(riot --validate ... 2&>1)"
if [[ -n "$X" ]]
then
exit 99
fi
)
echo $?
-------------
Yes. I'm already using a similar approach to validate Turtle files:

find . \
-type f \
-name "*.ttl" e
-exec sh \
-c 'if [[ $(riot --validate "{}" 2>&1) ]]; then echo "{}"; fi' \;

I was just thinking if there is simpler way.

- Jindřich
Andy Seaborne
2016-06-21 09:16:35 UTC
Permalink
Post by Jindřich Mynarz
Post by Andy Seaborne
capture the output and test it.
If in a subshell, the exit here will set the out $?
-------------
#!/bin/bash
(
X="$(riot --validate ... 2&>1)"
if [[ -n "$X" ]]
then
exit 99
fi
)
echo $?
-------------
find . \
-type f \
-name "*.ttl" e
-exec sh \
-c 'if [[ $(riot --validate "{}" 2>&1) ]]; then echo "{}"; fi' \;
I was just thinking if there is simpler way.
An exit code would be good - a contribution maybe?

(adding an error handler that notes when it is called and otherwise
passes through to the one that logs the messages would be my first line
of investigation).

Andy
Post by Jindřich Mynarz
- Jindřich
Andy Seaborne
2016-06-21 09:19:14 UTC
Permalink
Post by Andy Seaborne
An exit code would be good - a contribution maybe?
Recorded as:
https://issues.apache.org/jira/browse/JENA-1197

Loading...