mirror of
https://github.com/notwa/rc
synced 2024-11-05 03:39:02 -08:00
24 lines
648 B
Bash
Executable file
24 lines
648 B
Bash
Executable file
#!/usr/bin/env sh
|
|
# YES_ZSH
|
|
# YES_BASH
|
|
# YES_DASH
|
|
# YES_ASH
|
|
|
|
# does not work with busybox sed (yet?)
|
|
|
|
scramble() { ### @-
|
|
### scrambles text in a predictable way using regex.
|
|
###
|
|
### sacbremls ttex in a pdrceailtbe way unsig reegx.
|
|
###
|
|
### **TODO:** consider renaming because scramble(1) already exists.
|
|
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
|
|
local eggs='s/@\(\w\)\(\w\)\(\w\)/@\3\1@\2/g'
|
|
sed \
|
|
-e 's/\b\w/&@/g' \
|
|
-e "$eggs" -e "$eggs" -e "$eggs" -e "$eggs" \
|
|
-e "$eggs" -e "$eggs" -e "$eggs" -e "$eggs" \
|
|
-e 's/@//g'
|
|
}
|
|
|
|
[ -n "${preload+-}" ] || scramble "$@"
|