From 521aea6b4731a38fff5d8bb1ae877969c0bf3bc6 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Tue, 20 Feb 2018 03:02:42 +0100 Subject: [PATCH] Fix file_changed function for non-existent files. --- home/bin/update-profile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/home/bin/update-profile b/home/bin/update-profile index 4914b25..0e49f08 100755 --- a/home/bin/update-profile +++ b/home/bin/update-profile @@ -1,6 +1,16 @@ #!/bin/sh -e file_changed() { + if [ ! -f "$1" ]; then + if [ ! -f "$2" ]; then + return 0 + else + return 1 + fi + fi + if [ ! -f "$2" ]; then + return 1 + fi oldfilehash="$(sha1sum "$1" | awk '{print $1}')" newfilehash="$(sha1sum "$2" | awk '{print $1}')" [ "${oldfilehash}" != "${newfilehash}" ]