diff options
Diffstat (limited to 'desktop/modules/status')
| -rwxr-xr-x | desktop/modules/status/statusctl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/desktop/modules/status/statusctl b/desktop/modules/status/statusctl index 71ada07..6fbb689 100755 --- a/desktop/modules/status/statusctl +++ b/desktop/modules/status/statusctl @@ -48,12 +48,12 @@ esac file="$DIR/status.$mode" read_mode() { - local v - # An unreadable file reads as off, deliberately: a missing mode file is - # the normal state before anything has written one, and the redirect - # makes that fallback explicit rather than a side effect of a pipeline - # swallowing cat's exit status. - v="$(tr -d '[:space:]' < "$file" 2>/dev/null)" + local v="" + # A missing file is the normal state before anything has written one and + # reads as off. Guarding on existence keeps the shell's redirection error + # off stderr: `2>/dev/null` on the command cannot suppress a failure of + # its own input redirect. + [[ -e "$file" ]] && v="$(tr -d '[:space:]' < "$file" 2>/dev/null)" [[ "$v" == "1" ]] && printf '1' || printf '0' } |
