2
0

Make mpw_mkpw symlinkable.

This commit is contained in:
Maarten Billemont 2017-10-06 13:33:08 -04:00
parent 78c9618807
commit 81bd2e3065
2 changed files with 38 additions and 6 deletions

View File

@ -261,7 +261,10 @@ chr() {
# Outputs the decimal ASCII value of the given character. # Outputs the decimal ASCII value of the given character.
# #
ord() { ord() {
printf '%d' "'$1" local str=$1 s
for (( s=0; s < ${#str}; ++s )); do
printf '%d' "'${str:s:1}"
done
} # _____________________________________________________________________ } # _____________________________________________________________________
@ -274,7 +277,10 @@ ord() {
# Outputs the hexadecimal ASCII value of the given character. # Outputs the hexadecimal ASCII value of the given character.
# #
hex() { hex() {
printf '%x' "'$1" local str=$1 s
for (( s=0; s < ${#str}; ++s )); do
printf '%02X' "'${str:s:1}"
done
} # _____________________________________________________________________ } # _____________________________________________________________________
@ -287,7 +293,10 @@ hex() {
# Outputs the character that has the given hexadecimal ASCII value. # Outputs the character that has the given hexadecimal ASCII value.
# #
unhex() { unhex() {
printf "\\x$1" local hex=$1 h
for (( h=0; h < ${#hex}; h+=2 )); do
printf "\\x${hex:h:2}"
done
} # _____________________________________________________________________ } # _____________________________________________________________________
@ -1422,6 +1431,29 @@ shorten() {
# ______________________________________________________________________
# |__ CdSource ________________________________________________________________|
#
# cdsource [file]
#
# Change the current directory into the directory where the file is located, resolving symlinks.
#
cdsource() {
local source=${1:-${BASH_SOURCE[1]}}
while [[ $source ]]; do
[[ $source = */* ]] && cd "${source%/*}"
if [[ -L ${source##*/} ]]; then
source=$(readlink "${source##*/}")
else
source=
fi
done
} # _____________________________________________________________________
# ______________________________________________________________________ # ______________________________________________________________________
# |__ Up ________________________________________________________________| # |__ Up ________________________________________________________________|
# #

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source bashlib
cdsource
getword() { getword() {
local cat=$1 pop_limit=$2 words=() local cat=$1 pop_limit=$2 words=()
@ -19,9 +21,7 @@ declare -A categoryByCharacter=(
['v']=verb ['v']=verb
) )
templates=( templates=(
nvan ran # ~32.0 bit
anvr
anavan
) )
permutations=1 permutations=1