1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 02:19:03 -08:00

add compatibility flags for a bunch of scripts (part 4)

This commit is contained in:
Connor Olding 2024-07-23 05:34:17 -07:00
parent 7c9482c02c
commit 6bff3980fb
13 changed files with 17 additions and 17 deletions

View file

@ -1,8 +1,8 @@
#!/usr/bin/sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
sortip() { ### @- sort lines numerically by IPv4 segments.
sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n "$@"
LC_ALL=C sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n "$@"
}
[ -n "${preload+-}" ] || sortip "$@"

View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash +hush -ksh +mksh -oksh +osh +posh +yash +zsh
__subdue() { ### @subdue
### reconfigure your terminal's color scheme using a preset for [recolor.](#recolor)

2
sh/sum
View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash +hush -ksh +mksh +oksh +osh +posh +yash +zsh
sum() { ### @-
### compute the summation of its arguments without forking processes.

2
sh/sv
View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh YES_BB_AWK
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh YES_BB_AWK
sv() { ### @-
### collect the lastmost value of every key.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
trash() { ### @-
### output a given number of bytes from `/dev/random`.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh YES_BB_AWK
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh YES_BB_AWK
trunc() { ### @-
### truncate text to fit within your terminal using the unicode character `…`.
@ -12,8 +12,8 @@ trunc() { ### @-
### ```
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
COLUMNS=${COLUMNS:-$(tput cols)}
awk -vL=${1:-$COLUMNS} '{e=length()>L?"…":"";print substr($0,0,L-(e?1:0)) e}'
COLUMNS="${COLUMNS:-"$(tput cols)"}"
awk -vL="${1:-$COLUMNS}" '{e=length()>L?"…":"";print substr($0,0,L-(e?1:0)) e}'
}
[ -n "${preload+-}" ] || trunc "$@"

View file

@ -1,5 +1,5 @@
#!/usr/bin/env zsh
# compat: -ash -bash -dash +zsh
# compat: -ash -bash -dash -hush -ksh -mksh -oksh -osh -posh -yash +zsh
unarchive() { ### @- extract the contents of an archive file in one of many formats.
### borrowed from [prezto.](https://github.com/sorin-ionescu/prezto)

View file

@ -1,8 +1,8 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
unwrap() { ### @- join paragraphs into one line each.
awk '\''BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'\'
awk 'BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'
}
[ -n "${preload+-}" ] || unwrap "$@"

View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
v_domap() {
argc $# -eq 1 "$0" || return

View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
v_lower() { ### @- transform the contents of a variable to lowercase.
argc $# -eq 1 "$0" || return

View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
v_upper() { ### @- transform the contents of a variable to uppercase.
argc $# -eq 1 "$0" || return

2
sh/wat
View file

@ -1,5 +1,5 @@
#!/usr/bin/env zsh
# compat: -ash -bash -dash +zsh
# compat: -ash -bash -dash -hush -ksh -mksh -oksh -osh -posh -yash +zsh
# wat - a better and recursive which/whence
# via: https://leahneukirchen.org/dotfiles/tools.html

2
sh/xxp
View file

@ -1,5 +1,5 @@
#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
xxp() { ### @-
### act like `xxd -p`, but nicely formatted.