When I am running following code:
#!/bin/bash
PREVIOUS_COMMIT=e099d95d52b8fca99e47fd7cee5f782287178b27
SERVICE=service-web-prj1
if [ ! git diff "$PREVIOUS_COMMIT" HEAD --name-only | grep -qs "$SERVICE" ] || [ ! git diff "$PREVIOUS_COMMIT" HEAD --name-only | grep -qs 'service-web' ];
then
echo Didnt pass first
exit 0;
fi
echo passed first with $SERVICE
if ( ! echo "$SERVICE" | grep -q "^service-web" );
then
echo Didnt pass second
exit 0;
fi
echo passed second with $SERVICE
I am getting:
scripts/getLastCommit.1.sh: line 9: [: missing `]'
scripts/getLastCommit.1.sh: line 9: [: missing `]'
I looked around and everyone mention the space before the last "]" Which I have tripled check and I do have that
Anyone knows what I am doing wrong?
Thanks, Dennis
Figured out that this will do the trick for me:
if ! echo $GITDIFF | grep -q -e 'service-web*' -e $SERVICE;
[
is a command, not just syntax. At a bash prompt typehelp if
andhelp test
– glenn jackman Jun 09 '18 at 17:41