mirror of
https://github.com/notwa/rc
synced 2024-06-17 13:43:06 -07:00
prefer ||
over test ... -o ...
This commit is contained in:
parent
48ef5d6f0c
commit
c7603653b0
|
@ -28,7 +28,7 @@ document2() {
|
||||||
@-*)
|
@-*)
|
||||||
s="$code"
|
s="$code"
|
||||||
n="${s%%[!a-zA-Z0-9_-]*}" # substr first word (might not be one)
|
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
|
[ -n "$s" ] || break
|
||||||
s="${s#${s%%[!a-zA-Z0-9_-]*}}" # lstrip to end of word
|
s="${s#${s%%[!a-zA-Z0-9_-]*}}" # lstrip to end of word
|
||||||
s="${s#*[!a-zA-Z0-9_-]}" # lstrip to next word
|
s="${s#*[!a-zA-Z0-9_-]}" # lstrip to next word
|
||||||
|
@ -79,7 +79,7 @@ document2() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$s" != ' ' ]; then # don't bother unless it was set to something
|
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:
|
# just pass the remaining comment through:
|
||||||
if [ $o = 1 ]; then
|
if [ $o = 1 ]; then
|
||||||
# ensure one-liners are their in their own paragraph.
|
# ensure one-liners are their in their own paragraph.
|
||||||
|
|
|
@ -44,7 +44,7 @@ maybesudo_() ( ### @-
|
||||||
|
|
||||||
C|U|b|g|i|l|r|s|t)
|
C|U|b|g|i|l|r|s|t)
|
||||||
# C: close from (fd)
|
# C: close from (fd)
|
||||||
# U: other user (in conjunction wiht -l)
|
# U: other user (in conjunction with -l)
|
||||||
# b: background
|
# b: background
|
||||||
# g: group
|
# g: group
|
||||||
# i: simulate initial login (TODO)
|
# i: simulate initial login (TODO)
|
||||||
|
@ -57,7 +57,7 @@ maybesudo_() ( ### @-
|
||||||
;;
|
;;
|
||||||
|
|
||||||
u) # user
|
u) # user
|
||||||
if [ -z "$USER" -o "$OPTARG" != "$USER" ]; then
|
if [ -z "$USER" ] || [ "$OPTARG" != "$USER" ]; then
|
||||||
note 'maybesudo: users other than yourself are unsupported!'
|
note 'maybesudo: users other than yourself are unsupported!'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
2
sh/stfu
2
sh/stfu
|
@ -68,7 +68,7 @@ stfu() { ### @-
|
||||||
|
|
||||||
mkdir -p "$temp" || { printf "%s\n" "$0: failed to create temp directory" >&2; return 1; }
|
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 out="$temp/out_$time"
|
||||||
local err="$temp/err_$time"
|
local err="$temp/err_$time"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user