Author: Jeremy Huntwork <jhuntwork@lightcubesolutions.com>

Date:   Tue Apr 16 13:31:09 2019 -0700

    Improve testing of configuration file timestamp
    
      * Provide a default value for each so that the comparisons of the time
        of each file doesn't fail.
      * Two commands in the Makefile could acceptably fail, but would
        produce some ugly warnings.
    
    Signed-off-by: Pierre Labastie <pierre.labastie@neuf.fr>
This commit is contained in:
Pierre Labastie 2019-04-17 07:06:13 +00:00
parent 8589e90f5c
commit a22bfe1ab5
2 changed files with 9 additions and 10 deletions

View file

@ -11,7 +11,7 @@ CONFIG = menu
all: menuconfig
# @clear
@`grep RUN_ME configuration | sed -e 's@RUN_ME=\"@@' -e 's@\"@@' `
@$$(grep RUN_ME configuration 2>/dev/null | sed -e 's@RUN_ME=\"@@' -e 's@\"@@')
$(CONFIG)/conf:
$(MAKE) -C $(CONFIG) conf
@ -20,7 +20,7 @@ $(CONFIG)/mconf:
$(MAKE) -C $(CONFIG) ncurses conf mconf
menuconfig: $(CONFIG)/mconf
-@cp -a configuration configuration.old
@cp -a configuration configuration.old 2>/dev/null || true
@$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
config: $(CONFIG)/conf

15
jhalfs
View file

@ -124,15 +124,14 @@ esac
# If the user has not saved his configuration file, let's ask
# if he or she really wants to run this stuff
time_old=$(stat -c '%Y' configuration.old 2>/dev/null)
time_current=$(stat -c '%Y' configuration 2>/dev/null)
if [ "$(printf '%d' "$time_old")" -ge "$(printf '%d' "$time_current")" ]
then echo -n "Do you want to run jhalfs? yes/no (yes): "
time_current=$(stat -c '%Y' configuration 2>/dev/null || date +%s)
time_old=$(stat -c '%Y' configuration.old 2>/dev/null || printf '%s' "$time_current")
if [ "$(printf '%d' "$time_old")" -ge "$(printf '%d' "$time_current")" ] ; then
printf 'Do you want to run jhalfs? yes/no (yes): '
read -r ANSWER
if [ "x${ANSWER:0:1}" = "xn" ] || [ "x${ANSWER:0:1}" = "xN" ] ; then
echo "${nl_}Exiting gracefully.${nl_}"
exit
fi
case ${ANSWER:0:1} in
n|N) printf "\nExiting gracefully.\n"; exit ;;
esac
fi
# Change this to 0 to suppress almost all messages