#!/bin/sh set -e -f -u # This comment is used to simplify checking local copies of the script. Bump # this number every time a significant change is made to this script. # # AdGuard-Project-Version: 5 # TODO(a.garipov): Add pre-merge-commit. # Only show interactive prompts if there a terminal is attached to stdout. # While this technically doesn't guarantee that reading from /dev/tty works, # this should work reasonably well on all of our supported development systems # and in most terminal emulators. is_tty='0' if [ -t '1' ]; then is_tty='1' fi readonly is_tty # prompt is a helper that prompts the user for interactive input if that can be # done. If there is no terminal attached, it sleeps for two seconds, giving the # programmer some time to react, and returns with a zero exit code. prompt() { if [ "$is_tty" -eq '0' ]; then sleep 2 return 0 fi while true; do printf 'commit anyway? y/[n]: ' read -r ans