1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-18 01:53:22 -07:00

prefer || over test ... -o ...

This commit is contained in:
Connor Olding 2024-02-23 22:31:21 -08:00
parent 48ef5d6f0c
commit c7603653b0
3 changed files with 5 additions and 5 deletions

View File

@ -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.

View File

@ -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

View File

@ -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"