-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev-defaults
- Loading branch information
Showing
494 changed files
with
12,698 additions
and
6,250 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ basic.vim | |
|
||
# custom to dorothy | ||
user | ||
state |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/env bash | ||
|
||
function echo_if_empty() ( | ||
source "$DOROTHY/sources/stdinargs.bash" | ||
|
||
function help { | ||
cat <<-EOF >/dev/stderr | ||
ABOUT: | ||
Output <fallback> if <input> is empty. | ||
USAGE: | ||
echo-if-empty <fallback> [...options] [--] ...<input> | ||
echo-lines ...<input> | echo-if-empty <fallback> [...options] | ||
OPTIONS: | ||
<fallback> | --fallback=<fallback> | ||
The fallback to use if <input> is empty. | ||
$(stdinargs_options_help --) | ||
EXAMPLE: | ||
echo-if-empty 'my-fallback-value' | ||
my-fallback-value | ||
# exit status: 0 | ||
echo | echo-if-empty 'my-fallback-value' | ||
my-fallback-value | ||
# exit status: 0 | ||
echo 'a-value' | echo-if-empty 'my-fallback-value' | ||
'a-value' | ||
# exit status: 0 | ||
ALTERNATIVES: | ||
Use [ifne] from [moreutils], which is what we use in [eval-on-empty-stdin] and [eval-on-not-empty-stdin]. | ||
EOF | ||
if test "$#" -ne 0; then | ||
echo-error "$@" | ||
fi | ||
return 22 # EINVAL 22 Invalid argument | ||
} | ||
|
||
# process our own arguments, delegate everything else to stdinargs | ||
local rand="$RANDOM" | ||
local item option_fallback="$rand" option_args=() | ||
while test "$#" -ne 0; do | ||
item="$1" | ||
shift | ||
case "$item" in | ||
'--help' | '-h') help ;; | ||
'--fallback='*) option_fallback="${item#*=}" ;; | ||
# forward to stdinargs, however support mixing and matching of our options, with stdinarg options | ||
'--') | ||
option_args+=("$item" "$@") | ||
shift $# | ||
break | ||
;; | ||
'--'*) option_args+=("$item") ;; | ||
*) | ||
if test "$option_fallback" = "$rand"; then | ||
option_fallback="$item" | ||
else | ||
option_args+=("$item") | ||
fi | ||
;; | ||
esac | ||
done | ||
|
||
# checck for expected | ||
if test "$option_fallback" = "$rand"; then | ||
help "Missing required argument: <expected>" | ||
fi | ||
|
||
# action | ||
local inputs='' | ||
function on_inline { | ||
inputs+="$1" | ||
} | ||
function on_line { | ||
inputs+="$1"$'\n' | ||
} | ||
function on_finish { | ||
if is-empty-string -- "$inputs"; then | ||
print_string "$fallback" | ||
else | ||
print_string "$inputs" | ||
fi | ||
} | ||
stdinargs "${option_args[@]}" | ||
) | ||
|
||
# fire if invoked standalone | ||
if test "$0" = "${BASH_SOURCE[0]}"; then | ||
echo_if_empty "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.