I'm trying to implement agit commit hook that updates a BaseX database with updates committed to the git repo (the BaseX database is being used for search and link management).
My script is here:
https://github.com/dita-for-small-teams/dfst-git-commit-hooks/blob/develop/ post-commit
The important code is:
---------- addOrUpdate="git diff HEAD^ HEAD --name-only --diff-filter=AM"
# echo "Adding/Updating files:" for line in `${addOrUpdate}`; do cmd="basexclient -c "OPEN ${basexDatabase};REPLACE ${line} ${topDir}/${line};EXIT" ${basexOptions}" echo "Running cmd: ${cmd}" $($cmd) done
---------
When I run the script I'm getting this response:
Contrext01:docs ekimber$ ../../dita-for-small-teams/commit-hooks/git/post-commit Running cmd: basexclient -c "OPEN sample-project;REPLACE docs/topic-01.dita /Users/ekimber/workspace-dfst/dfst-sample-project/docs/docs/topic-01.dita;E XIT" -U admin -P admin -p 1984 -n localhost Stopped at , 1/6: Unknown command: "OPEN. Did you mean 'OPEN'? Contrext01:docs ekimber$
If I copy the command from the message and run it directly from the command line it works as expected.
There must be some subtlety of using base in this context but my bash fu is weak and I have no idea what I'm doing wrong--I can't see any obvious user error but there must be one.
Can anyone tell me what my bash scripting mistake is?
Is there a better way to do this sort of scripted interaction with basex? It didn't appear that BaseX scripts provided a way to take parameters--if they could then I'd just call a .bxs script with the relevant parameters. Short of generating the script and then running it, I couldn't think of a simpler way to do what I want that just using the -c option on the basexclient command.
Thanks,
Eliot
————— Eliot Kimber, Owner Contrext, LLC http://contrext.com