Compare commits
3 commits
d366245c2d
...
d80b61f490
Author | SHA1 | Date | |
---|---|---|---|
d80b61f490 | |||
faeda4feb9 | |||
23c0c18797 |
2 changed files with 9 additions and 21 deletions
11
sh/code.awk
11
sh/code.awk
|
@ -5,6 +5,10 @@ function append(line) {
|
|||
doc = doc line
|
||||
}
|
||||
|
||||
function eval(alias, target) {
|
||||
print alias "() { " target " \"${@}\"; }"
|
||||
}
|
||||
|
||||
function output(name, type) {
|
||||
print "↙ " type
|
||||
print name
|
||||
|
@ -20,13 +24,14 @@ function reset() {
|
|||
|
||||
BEGIN {
|
||||
RE_ANY = "(.*)"
|
||||
RE_BEGIN = "^"
|
||||
RE_CONST = "([_A-Z][_0-9A-Z]*)"
|
||||
RE_SET = "=.*"
|
||||
RE_SPACE = "[[:space:]]"
|
||||
RE_SPACES = RE_SPACE "*"
|
||||
RE_VAR = "([_a-z][_0-9a-z]*)"
|
||||
|
||||
RE_BEGIN = "^"
|
||||
RE_SPACES = RE_SPACE "*"
|
||||
|
||||
RE_END = RE_SPACES "$"
|
||||
RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{"
|
||||
|
||||
|
@ -79,7 +84,7 @@ BEGIN {
|
|||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
split(doc, array, "\n")
|
||||
for (item in array) {
|
||||
print array[item] " " m[1]
|
||||
eval(array[item], m[1])
|
||||
}
|
||||
reset()
|
||||
} else {
|
||||
|
|
19
sh/code.sh
19
sh/code.sh
|
@ -103,21 +103,6 @@ rwx_code_aliases() {
|
|||
echo "${_rwx_code_aliases}"
|
||||
}
|
||||
|
||||
# find alias function
|
||||
rwx_code_alias_function() {
|
||||
local target="${1}"
|
||||
local line name
|
||||
while IFS= read -r line; do
|
||||
name="$(echo "${line}" | awk "{print \$1}")"
|
||||
if [ "${name}" = "${target}" ]; then
|
||||
echo "${line}" |
|
||||
awk "{print \$2}"
|
||||
fi
|
||||
done <<EOF
|
||||
${_rwx_code_aliases_functions}
|
||||
EOF
|
||||
}
|
||||
|
||||
# find command function
|
||||
rwx_code_command_function() {
|
||||
local target="${1}"
|
||||
|
@ -204,9 +189,7 @@ rwx_code_load() {
|
|||
# parse aliases functions
|
||||
_rwx_code_aliases_functions="$(rwx_code_parse "aliases functions")"
|
||||
while IFS= read -r line; do
|
||||
text="$(echo "${line}" | sed "s| |() { |")"
|
||||
text="${text} \"\${@}\"; }"
|
||||
eval "${text}"
|
||||
eval "${line}"
|
||||
done <<EOF
|
||||
${_rwx_code_aliases_functions}
|
||||
EOF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue