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

Better error validation for CRX package manager tools #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cqput
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ do
STATUS=$(echo "${STATUS}" | sed '$d')
"${API}" -H "${STATUSCODE}"
EXITCODE2=${?}
if [ "${EXITCODE}" -ne 0 -o "${EXITCODE2}" -ne 0 ]
INNERHTTPCODE=$(echo "${STATUS}" | xmllint --xpath "string(//status/@code)" -)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that xmllint is installed, which may not be the case.

The general idea behind CQ UNIX Toolkit was to avoid external dependencies and rely on built-in commands only (curl, sed, etc).

PS I know that parsing XMLs with sed doesn't sound like fun :)

"${API}" -H "${INNERHTTPCODE}"
EXITCODE3=${?}
if [ "${EXITCODE}" -ne 0 -o "${EXITCODE2}" -ne 0 -o "${EXITCODE3}" -ne 0 ]
then
echo "${STATUS}" >&2
bad=1
else
echo "${STATUS}"
Expand Down
5 changes: 4 additions & 1 deletion cqrun
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ STATUSCODE=$(echo "${STATUS}" | tail -n 1)
"${API}" -H "${STATUSCODE}"
EXITCODE2=${?}
STATUS=$(echo "${STATUS}" | sed '$d')
INNERHTTPCODE=$(echo "${STATUS}" | xmllint --xpath "string(//status/@code)" -)
"${API}" -H "${INNERHTTPCODE}"
EXITCODE3=${?}
echo "${STATUS}"
exit $((EXITCODE + EXITCODE2))
exit $((EXITCODE + EXITCODE2 + EXITCODE3))