mirror of
https://github.com/notwa/rc
synced 2025-01-04 19:18:04 -08:00
improve ash compatiblity
surprisingly, [:space:] isn't supported, so just use plain spaces.
This commit is contained in:
parent
514b8e80d6
commit
1941e3253d
3 changed files with 14 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env false
|
||||
# for zsh, bash, and dash.
|
||||
# for ash, dash, bash, and zsh.
|
||||
[ -n "$ZSH_VERSION" -o -n "$BASH" ] && FANCY=1 || FANCY=0
|
||||
|
||||
# {{{1 utilities
|
||||
|
@ -132,6 +132,7 @@ alias gb='git --no-pager branch' ### @- display the current git branch.
|
|||
# being specific {{{2
|
||||
|
||||
[ -e "$HOME/python3" ] && alias py="~/python3" || alias py="python3"
|
||||
alias ash="busybox ash"
|
||||
alias pip="maybesudo -H pip3"
|
||||
alias revend='objcopy -I binary -O binary --reverse-bytes=4' ### @- reverse the 4-byte endianness of a single file. *this is an in-place operation!*
|
||||
alias aur="BUILDDIR=$HOME/src $HOME/sh/aur -jj"
|
||||
|
|
2
install
2
install
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
# this script is compatible with following shells:
|
||||
# dash, bash, zsh
|
||||
# ash, dash, bash, zsh
|
||||
|
||||
VERBOSE="${VERBOSE:-1}"
|
||||
|
||||
|
|
21
sh/document
21
sh/document
|
@ -2,6 +2,7 @@
|
|||
# NO_ZSH
|
||||
# NO_BASH
|
||||
# YES_DASH
|
||||
# YES_ASH
|
||||
# okay, so this probably does run with zsh and bash, but why bother?
|
||||
|
||||
# NOTE: a lot of boilerplate code is pulled from the pure sh bible:
|
||||
|
@ -15,13 +16,13 @@ document2() {
|
|||
[ "$e" != document ] || return 0 # doesn't play nicely yet, so skip it
|
||||
while IFS= read -r line; do
|
||||
: $((c+=1))
|
||||
# we only care about lines with our docstring marker on them:
|
||||
# we only care about lines with our docstring marker in them:
|
||||
case "$line" in *'###'*) :;; *) continue;; esac
|
||||
|
||||
# split by the marker:
|
||||
local code="${line%%###*}" docs="${line#*###}"
|
||||
code="${code#${code%%[![:space:]]*}}" # ltrim
|
||||
docs="${docs#${docs%%[![:space:]]*}}" # ltrim
|
||||
code="${code#${code%%[! ]*}}" # ltrim
|
||||
docs="${docs#${docs%%[! ]*}}" # ltrim
|
||||
|
||||
local s=' ' n='' # using a space to signify unset
|
||||
|
||||
|
@ -36,7 +37,7 @@ document2() {
|
|||
n="${s%%[!a-zA-Z0-9_-]*}" # substr that word
|
||||
done
|
||||
s="${docs#@-}" # substr the stuff after the hyphen
|
||||
s="${s#${s%%[![:space:]]*}}" # ltrim
|
||||
s="${s#${s%%[! ]*}}" # ltrim
|
||||
;;
|
||||
|
||||
@*-*)
|
||||
|
@ -45,19 +46,19 @@ document2() {
|
|||
s="${docs#*-}"
|
||||
|
||||
n="${n#@}" # substr the stuff after the at
|
||||
n="${n#${n%%[![:space:]]*}}" # ltrim
|
||||
n="${n%${n##*[![:space:]]}}" # rtrim
|
||||
n="${n#${n%%[! ]*}}" # ltrim
|
||||
n="${n%${n##*[! ]}}" # rtrim
|
||||
|
||||
s="${s#${s%%[![:space:]]*}}" # ltrim
|
||||
s="${s#${s%%[! ]*}}" # ltrim
|
||||
;;
|
||||
|
||||
@*)
|
||||
n="${docs#@}"
|
||||
n="${n#${n%%[![:space:]]*}}" # ltrim
|
||||
n="${docs#@}" # substr the stuff after the at
|
||||
n="${n#${n%%[! ]*}}" # ltrim
|
||||
;;
|
||||
|
||||
*)
|
||||
s="${docs#${docs%%[![:space:]]*}}" # ltrim
|
||||
s="${docs#${docs%%[! ]*}}" # ltrim
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in a new issue