2 # - Les variables GIT_AUTHOR_*, utilisées par git pour signer les commits,
3 # seront initialisées en fonction du contenu de ~/.gitconfig
4 # ou du login utilisé pour la connexion.
5 # - La fermeture du shell dans le cas où des modifications de /etc
6 # n'ont pas été enregistrées échouera avec un avertissement.
9 (*i
*) # NOTE: interactive shell
10 check_uncommitted
() {
11 if sudo
-n etckeeper unclean
2>/dev
/null
12 then printf '%s%s%s\n' >&2 "${tput_rev-}" "/etc has uncommitted changes: please use etckeeper commit." "${tput_sgr0-}"
13 CHECK_UNCOMMITED
="done" exec $SHELL -$
-
17 local ttyuser ttyuserhome conf
19 ttyuser
="$(stat -c "%U
" $(tty))"
20 ttyuserhome
="$(getent passwd "$ttyuser" | cut -d: -f6)"
21 conf
="$ttyuserhome/.gitconfig"
23 if [ -z "$GIT_AUTHOR_NAME" ] && [ -z "$GIT_AUTHOR_EMAIL" ]; then
24 if [ ! -z "$GIT_CONFIG_LOCAL" ] ||
[ ! -z "$GIT_CONFIG" ]
26 export GIT_AUTHOR_NAME
="$(git config --get user.name)"
27 export GIT_AUTHOR_EMAIL
="$(git config --get user.email)"
28 elif [ -r "$conf" ]; then
29 export GIT_AUTHOR_NAME
="$(git config --file "$conf" --get user.name)"
30 export GIT_AUTHOR_EMAIL
="$(git config --file "$conf" --get user.email)"
32 export GIT_AUTHOR_NAME
="$USER"
33 export GIT_AUTHOR_EMAIL
="$USER@$(hostname -f)"
39 if sudo
-n etckeeper unclean
2>/dev
/null
44 if [ "$CHECK_UNCOMMITED" != done ]
45 then trap check_uncommitted EXIT