From a765639c858c8d83ecbbb04b7e380b4b04acaa0c Mon Sep 17 00:00:00 2001 From: dtb Date: Sat, 10 Sep 2022 00:04:17 -0400 Subject: [PATCH] refinement --- xdg-sanity.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xdg-sanity.sh b/xdg-sanity.sh index 56ced9e..8a5aa7d 100755 --- a/xdg-sanity.sh +++ b/xdg-sanity.sh @@ -1,14 +1,20 @@ #!/bin/sh -set -e +set -ex argv0="$0" # cats out the configuration or {'\n', EOF} if it can't be found stream_config(){ - cat "$HOME"/.xdg-sanity.conf 2>/dev/null \ - || cat "$HOME"/.config/xdg-sanity.conf 2>/dev/null \ - || cat /etc/xdg-sanity/xdg-sanity.conf 2>/dev/null \ - || echo # empty line + for file in \ + "$HOME"/.config/xdg-sanity.conf \ + "$HOME"/.xdg-sanity.conf \ + /etc/xdg-sanity/xdg-sanity.conf \ + /dev/null + do + cat "$file" 2>/dev/null \ + && break \ + || true + done } # check if usage is valid