From c7603653b0b98bbfadbd590de6b93b3054e9bb49 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 23 Feb 2024 22:31:21 -0800 Subject: [PATCH] prefer `||` over `test ... -o ...` --- sh/document | 4 ++-- sh/maybesudo | 4 ++-- sh/stfu | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/document b/sh/document index 3c3d0c1..121494a 100755 --- a/sh/document +++ b/sh/document @@ -28,7 +28,7 @@ document2() { @-*) s="$code" n="${s%%[!a-zA-Z0-9_-]*}" # substr first word (might not be one) - while [ -z "$n" -o "$n" = function -o "$n" = alias ]; do + while [ -z "$n" ] || ["$n" = function ] || [ "$n" = alias ]; do [ -n "$s" ] || break s="${s#${s%%[!a-zA-Z0-9_-]*}}" # lstrip to end of word s="${s#*[!a-zA-Z0-9_-]}" # lstrip to next word @@ -79,7 +79,7 @@ document2() { fi if [ "$s" != ' ' ]; then # don't bother unless it was set to something - if [ -z "$n" -o -n "$s" ]; then # might only be a name, check that + if [ -z "$n" ] || [ -n "$s" ]; then # might only be a name, check that # just pass the remaining comment through: if [ $o = 1 ]; then # ensure one-liners are their in their own paragraph. diff --git a/sh/maybesudo b/sh/maybesudo index 557a5cf..253b713 100755 --- a/sh/maybesudo +++ b/sh/maybesudo @@ -44,7 +44,7 @@ maybesudo_() ( ### @- C|U|b|g|i|l|r|s|t) # C: close from (fd) - # U: other user (in conjunction wiht -l) + # U: other user (in conjunction with -l) # b: background # g: group # i: simulate initial login (TODO) @@ -57,7 +57,7 @@ maybesudo_() ( ### @- ;; u) # user - if [ -z "$USER" -o "$OPTARG" != "$USER" ]; then + if [ -z "$USER" ] || [ "$OPTARG" != "$USER" ]; then note 'maybesudo: users other than yourself are unsupported!' return 1 fi diff --git a/sh/stfu b/sh/stfu index eb102ef..c235d29 100755 --- a/sh/stfu +++ b/sh/stfu @@ -68,7 +68,7 @@ stfu() { ### @- mkdir -p "$temp" || { printf "%s\n" "$0: failed to create temp directory" >&2; return 1; } - while [ -e "$temp/out_$time" -o -e "$temp/err_$time" ]; do time=$((time+1)); done + while [ -e "$temp/out_$time" ] || [ -e "$temp/err_$time" ]; do time=$((time+1)); done local out="$temp/out_$time" local err="$temp/err_$time"