@cratis/pi 7.150.0 → 7.150.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -77,8 +77,8 @@ function addw(text, kind, k) {
|
|
|
77
77
|
for (k = 1; k <= length(text); k++) { wmask = wmask (quote_boundary ? toupper(kind) : kind); quote_boundary = 0 }
|
|
78
78
|
}
|
|
79
79
|
function flush_word() {
|
|
80
|
-
if (inword) { W[++nw] = word; WP[nw] = wplain; WM[nw] = wmask }
|
|
81
|
-
word = ""; wmask = ""; inword = 0; wquoted = 0; wplain = 0; quote_boundary = 0
|
|
80
|
+
if (inword) { W[++nw] = word; WP[nw] = wplain; WM[nw] = wmask; WU[nw] = wunquoted }
|
|
81
|
+
word = ""; wmask = ""; inword = 0; wquoted = 0; wplain = 0; quote_boundary = 0; wunquoted = 0
|
|
82
82
|
}
|
|
83
83
|
# Decodes the body of an ANSI-C string $'...' (i is just after the opening quote) into the word and returns the
|
|
84
84
|
# position after the closing quote. The same decoder is in cratis-guard-store-mutations.sh (`ansi_c`).
|
|
@@ -352,17 +352,49 @@ function literal_shape(A, M, n, k, j, b, words, count, pattern, ended, w, pat
|
|
|
352
352
|
}
|
|
353
353
|
return b != "rg" || paths > 0
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
# Every character that can come from command output, directly or through a parameter expansion holding it, is a wildcard.
|
|
356
|
+
function output_wild(w, m, k, j, x, depth, found, r, span) {
|
|
357
|
+
delete span
|
|
358
|
+
for (k = 1; k <= length(w); k++) {
|
|
359
|
+
if (substr(w, k, 2) != "$" "{" || tolower(substr(m, k, 1)) == "l") continue
|
|
360
|
+
depth = 0; found = 0
|
|
361
|
+
for (j = k + 1; j <= length(w); j++) {
|
|
362
|
+
if (tolower(substr(m, j, 1)) == "c") found = 1
|
|
363
|
+
else if (substr(w, j, 1) == "{") depth++
|
|
364
|
+
else if (substr(w, j, 1) == "}" && --depth == 0) break
|
|
365
|
+
}
|
|
366
|
+
if (found) for (x = k; x <= j; x++) span[x] = 1
|
|
367
|
+
}
|
|
368
|
+
for (k = 1; k <= length(w); k++) r = r ((k in span) || tolower(substr(m, k, 1)) == "c" ? "*" : substr(w, k, 1))
|
|
369
|
+
return r
|
|
370
|
+
}
|
|
371
|
+
# Unquoted output can also split into several words: scan each suffix that starts at output text.
|
|
372
|
+
function split_scan(w, m, k, r, hit) {
|
|
373
|
+
r = output_wild(w, m)
|
|
374
|
+
for (k = 1; k <= length(r); k++) {
|
|
375
|
+
if (substr(r, k, 1) != "*" || substr(r, k + 1, 1) == "*") continue
|
|
376
|
+
hit = stem_scan(substr(r, k), "raw", "expanding"); if (hit != "") return hit
|
|
377
|
+
if (substr(r, k + 1, 1) !~ /^[\/]?$/) { hit = stem_scan("." substr(r, k), "raw", "expanding"); if (hit != "") return hit }
|
|
378
|
+
}
|
|
379
|
+
return ""
|
|
380
|
+
}
|
|
381
|
+
function end_cmd( k, m, w, j, hit, exempt) {
|
|
356
382
|
flush_word()
|
|
357
383
|
if (nw > 0) {
|
|
358
384
|
commands++
|
|
359
385
|
regex_slots(W, 1, nw)
|
|
360
386
|
for (k = 1; k <= nw; k++) {
|
|
361
387
|
if (is_assign(W[k])) set_var(W[k], WM[k])
|
|
362
|
-
|
|
363
|
-
|
|
388
|
+
exempt = (k in RP) && !WU[k]
|
|
389
|
+
if (exempt && RP[k] < 0) continue
|
|
390
|
+
w = exempt ? substr(W[k], 1, RP[k]) : W[k]
|
|
364
391
|
hit = stem_scan(w, "raw", expands(w, WM[k]) ? "expanding" : 0); if (TAINT == "") TAINT = hit
|
|
365
|
-
|
|
392
|
+
# Command output may supply any text, including several names: judge it as an unresolved wildcard.
|
|
393
|
+
if (!exempt && index(WM[k], "c") + index(WM[k], "C") > 0) {
|
|
394
|
+
hit = stem_scan(output_wild(W[k], WM[k]), "raw", "expanding"); if (TAINT == "") TAINT = hit
|
|
395
|
+
if (WU[k]) { hit = split_scan(W[k], WM[k]); if (TAINT == "") TAINT = hit }
|
|
396
|
+
}
|
|
397
|
+
if (!exempt && expands(W[k], WM[k])) {
|
|
366
398
|
resolve(W[k], WM[k])
|
|
367
399
|
for (j = 1; j <= nalt; j++) { hit = stem_scan(ALT[j], "resolved"); if (TAINT == "") TAINT = hit }
|
|
368
400
|
}
|
|
@@ -379,7 +411,7 @@ function end_cmd( k, m, w, j, hit) {
|
|
|
379
411
|
V[++m] = w; VM[m] = WM[k]
|
|
380
412
|
}
|
|
381
413
|
if (m > 0) { check_inputs(V, 1, m); analyze(V, 1, m) }
|
|
382
|
-
delete W; delete WP; delete WM; delete V; delete VM; nw = 0
|
|
414
|
+
delete W; delete WP; delete WM; delete WU; delete V; delete VM; nw = 0
|
|
383
415
|
}
|
|
384
416
|
function cmdsub(s, i, n, start, depth, c, j) {
|
|
385
417
|
complex = 1
|
|
@@ -417,7 +449,7 @@ function read_heredocs(s, i, n, h, e, line, cmp, body) {
|
|
|
417
449
|
return i
|
|
418
450
|
}
|
|
419
451
|
function tokenize(s, i, n, c, c2, j, dash, delim) {
|
|
420
|
-
n = length(s); i = 1; nw = 0; word = ""; wmask = ""; inword = 0; wquoted = 0; wplain = 0; nheredoc = 0; hd_shell = 0; quote_boundary = 0
|
|
452
|
+
n = length(s); i = 1; nw = 0; word = ""; wmask = ""; inword = 0; wquoted = 0; wplain = 0; wunquoted = 0; nheredoc = 0; hd_shell = 0; quote_boundary = 0
|
|
421
453
|
delete W; delete WP; delete WM
|
|
422
454
|
while (i <= n) {
|
|
423
455
|
c = substr(s, i, 1)
|
|
@@ -451,10 +483,10 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
|
|
|
451
483
|
}
|
|
452
484
|
continue
|
|
453
485
|
}
|
|
454
|
-
if (c == "$" && substr(s, i + 1, 1) == "(") { wquoted = 1; inword = 1; i = cmdsub(s, i + 2, n); addw("x", "c"); continue }
|
|
486
|
+
if (c == "$" && substr(s, i + 1, 1) == "(") { wquoted = 1; inword = 1; wunquoted = 1; i = cmdsub(s, i + 2, n); addw("x", "c"); continue }
|
|
455
487
|
if (c == "`") {
|
|
456
488
|
complex = 1
|
|
457
|
-
wquoted = 1; inword = 1
|
|
489
|
+
wquoted = 1; inword = 1; wunquoted = 1
|
|
458
490
|
j = index(substr(s, i + 1), "`")
|
|
459
491
|
if (j == 0) { i = n + 1; continue }
|
|
460
492
|
enqueue(substr(s, i + 1, j - 1)); i += j + 1; addw("x", "c"); continue
|