@fnndsc/brasa 0.48.1 → 0.49.0
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.
- package/dist/buildinfo.json +1 -1
- package/dist/builtins/fs/pull.js +7 -0
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/help.js +16 -0
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/proc.js +8 -1
- package/dist/builtins/proc.js.map +1 -1
- package/dist/builtins/res/gather.process.js +6 -1
- package/dist/builtins/res/gather.process.js.map +1 -1
- package/dist/builtins/sys/echo.d.ts +47 -0
- package/dist/builtins/sys/echo.js +182 -0
- package/dist/builtins/sys/echo.js.map +1 -0
- package/dist/core/coreCommands.js +5 -0
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/engine.js +11 -0
- package/dist/core/engine.js.map +1 -1
- package/dist/core/preprocess.js +3 -2
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/variables.js +2 -1
- package/dist/core/variables.js.map +1 -1
- package/dist/lib/completer/index.js +2 -1
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +0 -7
- package/dist/lib/parser.js +4 -1
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/quoting.d.ts +40 -0
- package/dist/lib/quoting.js +70 -0
- package/dist/lib/quoting.js.map +1 -0
- package/dist/lib/semicolonParser.d.ts +0 -7
- package/dist/lib/semicolonParser.js +6 -4
- package/dist/lib/semicolonParser.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Quoting: when a backslash escapes the character after it.
|
|
3
|
+
*
|
|
4
|
+
* POSIX's rule, read by every parser that splits a line (words, `;`, `|`,
|
|
5
|
+
* `>`, `$( … )`, completion), so no split disagrees with another:
|
|
6
|
+
*
|
|
7
|
+
* - inside single quotes every character is literal, a backslash included;
|
|
8
|
+
* - inside double quotes a backslash escapes only `$`, `` ` ``, `"`, `\` and
|
|
9
|
+
* newline, and before anything else it stays as written;
|
|
10
|
+
* - outside quotes a backslash escapes the next character, whatever it is.
|
|
11
|
+
*
|
|
12
|
+
* So `printf '%s\n' a` hands printf its `\n`, `grep '\.mgz$'` its `\.`, and
|
|
13
|
+
* `"a\"b"` is still one word holding a quote (#1258).
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
/** What a backslash escapes inside double quotes; before anything else it stays. */
|
|
18
|
+
const DOUBLE_QUOTE_ESCAPES = new Set(['$', '`', '"', '\\', '\n']);
|
|
19
|
+
/**
|
|
20
|
+
* Whether a backslash, where it stands, escapes the character after it.
|
|
21
|
+
*
|
|
22
|
+
* @param inSingle - Whether it stands inside single quotes.
|
|
23
|
+
* @param inDouble - Whether it stands inside double quotes.
|
|
24
|
+
* @param next - The character after it, or undefined at the line's end.
|
|
25
|
+
* @returns True when the two are one escaped character; false when the
|
|
26
|
+
* backslash is a character of its own.
|
|
27
|
+
*/
|
|
28
|
+
export function backslash_escapesNext(inSingle, inDouble, next) {
|
|
29
|
+
if (inSingle)
|
|
30
|
+
return false;
|
|
31
|
+
if (!inDouble)
|
|
32
|
+
return true;
|
|
33
|
+
return next !== undefined && DOUBLE_QUOTE_ESCAPES.has(next);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Finds a quote a line opens and never closes, reading quotes by the rule
|
|
37
|
+
* above, so a refusal names exactly what the word parser would have run
|
|
38
|
+
* past (#1260).
|
|
39
|
+
*
|
|
40
|
+
* @param line - The line.
|
|
41
|
+
* @returns The open quote, or null when every quote closes.
|
|
42
|
+
*/
|
|
43
|
+
export function quoteOpen_find(line) {
|
|
44
|
+
let inSingle = false;
|
|
45
|
+
let inDouble = false;
|
|
46
|
+
let openedAt = 0;
|
|
47
|
+
for (let at = 0; at < line.length; at++) {
|
|
48
|
+
const char = line[at];
|
|
49
|
+
if (char === '\\' && backslash_escapesNext(inSingle, inDouble, line[at + 1])) {
|
|
50
|
+
at++;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (char === "'" && !inDouble) {
|
|
54
|
+
inSingle = !inSingle;
|
|
55
|
+
if (inSingle)
|
|
56
|
+
openedAt = at + 1;
|
|
57
|
+
}
|
|
58
|
+
else if (char === '"' && !inSingle) {
|
|
59
|
+
inDouble = !inDouble;
|
|
60
|
+
if (inDouble)
|
|
61
|
+
openedAt = at + 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (inSingle)
|
|
65
|
+
return { quote: "'", column: openedAt };
|
|
66
|
+
if (inDouble)
|
|
67
|
+
return { quote: '"', column: openedAt };
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=quoting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quoting.js","sourceRoot":"","sources":["../../src/lib/quoting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,oFAAoF;AACpF,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvF;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAiB,EAAE,QAAiB,EAAE,IAAwB;IAClG,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,IAAI,KAAK,SAAS,IAAI,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC;AAQD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,QAAQ,GAAY,KAAK,CAAC;IAC9B,IAAI,QAAQ,GAAY,KAAK,CAAC;IAC9B,IAAI,QAAQ,GAAW,CAAC,CAAC;IACzB,KAAK,IAAI,EAAE,GAAW,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;QAChD,MAAM,IAAI,GAAW,IAAI,CAAC,EAAE,CAAW,CAAC;QACxC,IAAI,IAAI,KAAK,IAAI,IAAI,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAAC,EAAE,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;QACjG,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,QAAQ,GAAG,CAAC,QAAQ,CAAC;YACrB,IAAI,QAAQ;gBAAE,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACrC,QAAQ,GAAG,CAAC,QAAQ,CAAC;YACrB,IAAI,QAAQ;gBAAE,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IACD,IAAI,QAAQ;QAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACtD,IAAI,QAAQ;QAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Semicolon command parser
|
|
3
|
-
*
|
|
4
|
-
* Parses semicolon-separated commands while respecting quotes.
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
1
|
/**
|
|
9
2
|
* Parses a command line for semicolon separators and returns individual commands.
|
|
10
3
|
* Respects quoted strings - semicolons inside quotes are not treated as separators.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
|
+
import { backslash_escapesNext } from './quoting.js';
|
|
8
9
|
/**
|
|
9
10
|
* Parses a command line for semicolon separators and returns individual commands.
|
|
10
11
|
* Respects quoted strings - semicolons inside quotes are not treated as separators.
|
|
@@ -28,14 +29,15 @@ export function semicolons_parse(line) {
|
|
|
28
29
|
let escapeNext = false;
|
|
29
30
|
for (let i = 0; i < line.length; i++) {
|
|
30
31
|
const char = line[i];
|
|
31
|
-
// A backslash escapes
|
|
32
|
-
// word tokenizer and the pipe and redirect parsers read
|
|
33
|
-
// quote neither opens nor closes a quote, so `
|
|
32
|
+
// A backslash escapes as POSIX quoting says (lib/quoting.ts), the rule
|
|
33
|
+
// the word tokenizer and the pipe and redirect parsers read: an escaped
|
|
34
|
+
// quote neither opens nor closes a quote, so `"it\"s; x"` is one command,
|
|
35
|
+
// and in single quotes a backslash is a character, so `'a\'; b` is two.
|
|
34
36
|
if (escapeNext) {
|
|
35
37
|
currentCommand += char;
|
|
36
38
|
escapeNext = false;
|
|
37
39
|
}
|
|
38
|
-
else if (char === '\\') {
|
|
40
|
+
else if (char === '\\' && backslash_escapesNext(inSingleQuote, inDoubleQuote, line[i + 1])) {
|
|
39
41
|
currentCommand += char;
|
|
40
42
|
escapeNext = true;
|
|
41
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semicolonParser.js","sourceRoot":"","sources":["../../src/lib/semicolonParser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"semicolonParser.js","sourceRoot":"","sources":["../../src/lib/semicolonParser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,cAAc,GAAW,EAAE,CAAC;IAChC,IAAI,aAAa,GAAY,KAAK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