mawk/filter
This commit is contained in:
parent
cc4c0e967e
commit
b0abc4db45
1 changed files with 31 additions and 8 deletions
|
@ -1,3 +1,11 @@
|
|||
function alias_function(alias, name) {
|
||||
print alias "() { " name " \"${@}\"; }"
|
||||
}
|
||||
|
||||
function alias_variable(alias, name) {
|
||||
print alias "() { echo \"${" name "}\"; }"
|
||||
}
|
||||
|
||||
function append(line) {
|
||||
if (doc) {
|
||||
doc = doc "\n"
|
||||
|
@ -5,12 +13,20 @@ function append(line) {
|
|||
doc = doc line
|
||||
}
|
||||
|
||||
function alias_function(alias, target) {
|
||||
print alias "() { " target " \"${@}\"; }"
|
||||
function extract(string, type) {
|
||||
if (type == "alias") {
|
||||
split(string, array, "#=")
|
||||
return trim(array[2])
|
||||
} else if (type == "command") {
|
||||
split(string, array, "#/")
|
||||
return trim(array[2])
|
||||
} else if (type == "function") {
|
||||
split(string, array, "()")
|
||||
return trim(array[1])
|
||||
} else if ((type == "constant") || (type == "variable")) {
|
||||
split(string, array, "=")
|
||||
return trim(array[1])
|
||||
}
|
||||
|
||||
function alias_variable(alias, target) {
|
||||
print alias "() { echo \"${" target "}\"; }"
|
||||
}
|
||||
|
||||
function output(name, type) {
|
||||
|
@ -26,6 +42,13 @@ function reset() {
|
|||
}
|
||||
}
|
||||
|
||||
function trim(string) {
|
||||
text = string
|
||||
sub("^[\t ]*", "", text)
|
||||
sub("[\t ]*$", "", text)
|
||||
return text
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
RE_ANY = "(.*)"
|
||||
RE_BEGIN = "^"
|
||||
|
@ -63,8 +86,8 @@ BEGIN {
|
|||
|
||||
{
|
||||
if (action == "filter") {
|
||||
if (match($0, re[target], m)) {
|
||||
unique[m[1]] = ""
|
||||
if (match($0, re[target])) {
|
||||
unique[extract($0, target)] = ""
|
||||
}
|
||||
} else if (action == "tasks") {
|
||||
if (match($0, RE_MODULE, m)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue