#!/bin/bash cd src/libos output=$(cargo fmt --all -- --check 2>&1) retval=$? if [[ $retval -eq 0 ]] then exit 0 elif [[ $retval -eq 1 ]] then echo "Rust format suggestsions (generated by \`cd src/libos && cargo fmt --all -- --check\`):" echo echo "$output" echo echo "To get rid of the format warnings above, run \`cargo fmt\` before the next commit." exit 1 else echo "Warning: \`cargo fmt\` is not available." exit 1 fi