From addf7d1070b6edadf639c9616fba98f739157e80 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Mon, 2 Aug 2021 14:08:00 -0700 Subject: [PATCH] just conditionally source preload() instead of inlining it also try out argc in stfu --- sh/baks | 2 +- sh/preload | 7 ------- sh/sc | 2 +- sh/scropt | 2 +- sh/stfu | 6 +++--- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/sh/baks b/sh/baks index 380703a..3c8de16 100644 --- a/sh/baks +++ b/sh/baks @@ -32,6 +32,6 @@ baks() { ### @- return $ret } -preload() { local preload='set -- $@'; while [ $# -gt 0 ]; do . ~/sh/$1 || exit 2; shift; done; } +[ -n "${preload+-}" ] || . ~/sh/preload || exit 2 eval ${preload:-preload} note [ -n "${preload+-}" ] || baks "$@" diff --git a/sh/preload b/sh/preload index 8f7e02a..32bad98 100644 --- a/sh/preload +++ b/sh/preload @@ -1,11 +1,4 @@ #!/usr/bin/env false -# NO_ZSH -# NO_BASH -# NO_DASH -# NO_ASH -# NOTE: this is actually compatible with all of the above shells; -# i just really don't want it being sourced by accident. -# this file really only exists for documentation purposes. preload() { ### @- handle dependencies within the [`~/sh/`](/sh) directory. ### this function contains more comments than code, so you should read it. diff --git a/sh/sc b/sh/sc index c4a248c..994daae 100755 --- a/sh/sc +++ b/sh/sc @@ -62,6 +62,6 @@ sc() { ### @- return 0 } -preload() { local preload='set -- $@'; while [ $# -gt 0 ]; do . ~/sh/$1 || exit 2; shift; done; } +[ -n "${preload+-}" ] || . ~/sh/preload || exit 2 eval ${preload:-preload} ea [ -n "${preload+-}" ] || sc "$@" diff --git a/sh/scropt b/sh/scropt index e759de9..7efbd2f 100755 --- a/sh/scropt +++ b/sh/scropt @@ -14,6 +14,6 @@ scropt() { ### @- [ $? -eq 0 ] && echo "$fn" || return $? } -preload() { local preload='set -- $@'; while [ $# -gt 0 ]; do . ~/sh/$1 || exit 2; shift; done; } +[ -n "${preload+-}" ] || . ~/sh/preload || exit 2 eval ${preload:-preload} now [ -n "${preload+-}" ] || scropt "$@" diff --git a/sh/stfu b/sh/stfu index bffa2dd..0b27a5c 100644 --- a/sh/stfu +++ b/sh/stfu @@ -41,7 +41,7 @@ stfu() { ### @- ### WARNING: The system cannot find the file specified. ### asses ### ``` - [ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; } + argc -ge 1 "$0" "$@" || return local dirty=0 temp="$STFU_DIR" if [ -z "$temp" ]; then @@ -99,6 +99,6 @@ stfu() { ### @- return $ret } -preload() { local preload='set -- $@'; while [ $# -gt 0 ]; do . ~/sh/$1 || exit 2; shift; done; } -eval ${preload:-preload} echo2 note +[ -n "${preload+-}" ] || . ~/sh/preload || exit 2 +eval ${preload:-preload} argc echo2 note [ -n "${preload+-}" ] || stfu "$@"