During development (multiple people in the team) sometimes composer install returns:
composer install
Warning: The lock file is not up to date with the latest change
For composer < 1.3.0
Extending from @Domster, the solution in pure bash:
COMPOSER_IN_SYNC=$(expr "`cat composer.lock | grep '"hash":' | cut -d'"' -f4`" = "`md5sum composer.json | cut -d ' ' -f 1`")
$COMPOSER_IN_SYNC will be 0 or 1 respectively.
$COMPOSER_IN_SYNC
0
1