Compare commits
No commits in common. "b62edad33c077624fe63a561f6c242ddb6e2f888" and "d80b61f490de04e388f2af1e5909b30373691c8a" have entirely different histories.
b62edad33c
...
d80b61f490
3 changed files with 24 additions and 34 deletions
|
@ -116,7 +116,6 @@ Two interpreted languages for flexibility.
|
|||
* tmux
|
||||
* get unresolved path for new panes & windows
|
||||
* source code
|
||||
* bash completion
|
||||
* doc parsing algorithm
|
||||
* install commands
|
||||
* remove existing before
|
||||
|
|
35
sh/code.awk
35
sh/code.awk
|
@ -46,11 +46,11 @@ BEGIN {
|
|||
RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END
|
||||
RE_VARIABLE = RE_BEGIN RE_VAR RE_SET RE_END
|
||||
|
||||
alias = 0
|
||||
command = 0
|
||||
f = ""
|
||||
match_alias = 0
|
||||
match_command = 0
|
||||
match_module = 0
|
||||
reset()
|
||||
module = 0
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -96,22 +96,7 @@ BEGIN {
|
|||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
split(doc, array, "\n")
|
||||
for (item in array) {
|
||||
eval(array[item], m[1])
|
||||
}
|
||||
reset()
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
} else if (action == "command function") {
|
||||
if (match($0, RE_COMMAND, m)) {
|
||||
append(m[1])
|
||||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
split(doc, array, "\n")
|
||||
for (item in array) {
|
||||
if (item == target) {
|
||||
print m[1]
|
||||
exit
|
||||
}
|
||||
print array[item] " " m[1]
|
||||
}
|
||||
reset()
|
||||
} else {
|
||||
|
@ -130,12 +115,12 @@ BEGIN {
|
|||
} else if (match($0, RE_ALIAS, m)) {
|
||||
append("= " m[1])
|
||||
if (m[1] == target) {
|
||||
match_alias = 1
|
||||
alias = 1
|
||||
}
|
||||
} else if (match($0, RE_COMMAND, m)) {
|
||||
append("/ " m[1])
|
||||
if (m[1] == target) {
|
||||
match_command = 1
|
||||
command = 1
|
||||
}
|
||||
# set
|
||||
} else if (match($0, RE_CONSTANT, m)) {
|
||||
|
@ -154,15 +139,15 @@ BEGIN {
|
|||
} else if (match($0, RE_MODULE, m)) {
|
||||
reset()
|
||||
if (m[1] == target) {
|
||||
match_module = 1
|
||||
module = 1
|
||||
}
|
||||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
f = m[1]
|
||||
} else if (match($0, RE_CLOSE, m)) {
|
||||
if (match_alias) {
|
||||
if (alias) {
|
||||
print "= " target
|
||||
output(f, "function")
|
||||
} else if (match_command) {
|
||||
} else if (command) {
|
||||
print "/ " target
|
||||
output(f, "function")
|
||||
} else if (f == target) {
|
||||
|
@ -172,7 +157,7 @@ BEGIN {
|
|||
reset()
|
||||
}
|
||||
} else {
|
||||
if (match_module) {
|
||||
if (module) {
|
||||
output(target, "module")
|
||||
} else {
|
||||
reset()
|
||||
|
|
22
sh/code.sh
22
sh/code.sh
|
@ -105,13 +105,17 @@ rwx_code_aliases() {
|
|||
|
||||
# find command function
|
||||
rwx_code_command_function() {
|
||||
local name="${1}"
|
||||
[ -n "${name}" ] || return
|
||||
rwx_code |
|
||||
awk \
|
||||
--assign action="command function" \
|
||||
--assign target="${name}" \
|
||||
"${_rwx_code_awk}"
|
||||
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_commands_functions}
|
||||
EOF
|
||||
}
|
||||
|
||||
# show the cached aliases and functions
|
||||
|
@ -192,7 +196,9 @@ EOF
|
|||
# parse commands functions
|
||||
_rwx_code_commands_functions="$(rwx_code_parse "commands functions")"
|
||||
while IFS= read -r line; do
|
||||
eval "${line}"
|
||||
text="$(echo "${line}" | sed "s| |() { |")"
|
||||
text="${text} \"\${@}\"; }"
|
||||
eval "${text}"
|
||||
done <<EOF
|
||||
${_rwx_code_commands_functions}
|
||||
EOF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue