approval-md 0.4.3 → 0.4.5

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.
@@ -0,0 +1,212 @@
1
+ /**
2
+ * `date` in its display forms (APRV-508).
3
+ *
4
+ * The classifier's `date-read` row asks this file one question of an argv and
5
+ * the assignments in front of it: is this a `date` that only PRINTS a time,
6
+ * reading no file to do it?
7
+ *
8
+ * `date` has two jobs. One prints a time; the other sets the system clock, and
9
+ * the setting forms are spelled with the same binary and overlapping flags.
10
+ * So this reads the argv the way an option parser does and answers `false` for
11
+ * anything it does not recognise as display-only. `false` is the fail-closed
12
+ * answer: the classifier row does not match, and the command keeps the
13
+ * `unclassified` refusal it had before this row existed.
14
+ *
15
+ * Two implementations are in scope, and an argv is accepted only where both
16
+ * read it as a display: GNU coreutils (getopt) and uutils coreutils 0.10, the
17
+ * `date` the hosted Agent Village boxes run (clap). Where they differ the
18
+ * stricter reading wins: a required value may not start with `-` (getopt takes
19
+ * it as the value, clap may take it as the next flag), and long options match
20
+ * by EXACT name only (getopt and clap both accept a unique prefix, so `--se`
21
+ * is `--set` to both).
22
+ *
23
+ * Accepted, and nothing else:
24
+ *
25
+ * - no arguments at all (`date`);
26
+ * - at most one operand, and it must start with `+` (the output format). Any
27
+ * other operand is a clock setting (`MMDDhhmm[[CC]YY][.ss]`) on GNU, BSD and
28
+ * uutils alike;
29
+ * - `-u`, `--utc`, `--universal` (print in UTC);
30
+ * - `-R`, `--rfc-2822`, `--rfc-email`;
31
+ * - `-I` alone or with an ATTACHED precision (`-Iseconds`), and `--iso-8601`
32
+ * alone or with `=precision`;
33
+ * - `--rfc-3339=FMT` or `--rfc-3339 FMT`, FMT one of `date`, `seconds`, `ns`;
34
+ * - `-d STRING`, `-ud STRING`, `--date=STRING`, `--date STRING`: the string is
35
+ * parsed and printed, never applied to the clock. A `TZ="…"` inside the
36
+ * string names a zone and is held to {@link isZoneValue};
37
+ * - `--debug`, `--resolution`, `-h`/`--help`, `-V`/`--version`, which print
38
+ * diagnostics or text and read nothing;
39
+ * - the clusters `-uR`, `-Ru` and `-ud`, and no other: a cluster is accepted
40
+ * only by its exact spelling.
41
+ *
42
+ * Declined, so `unclassified` as before:
43
+ *
44
+ * - `-s`/`--set` (sets the clock), in any spelling or cluster;
45
+ * - `-f`/`--file` (reads a file's lines and echoes the bad ones back; on BSD
46
+ * `-f` is an input format that sets the clock without `-j`);
47
+ * - `-r`/`--reference` in EVERY spelling. It prints a file's modification
48
+ * time, which is a read of that file's metadata, and the agents this row
49
+ * exists for need the clock rather than a file's mtime. Admitting it would
50
+ * put a second spelling of `stat` behind a row whose whole claim is that it
51
+ * reads no file, so it stays refused;
52
+ * - BSD's `-j`/`-v`/`-n`, a bare `--`, every long-option abbreviation, an
53
+ * attached short value (`-d@0`, `-d=@0`), and every cluster not listed;
54
+ * - any word this file cannot read literally: one carrying `$`, a backtick, a
55
+ * glob or a brace, since the shell may split or expand it into flags this
56
+ * parse never saw. The classifier also declines a segment with a
57
+ * substituted word;
58
+ * - an assignment other than {@link DATE_ENV_NAMES}, and one of those whose
59
+ * value could name a file (`TZ=/etc/x`, `TZ=:../x`, `LC_ALL=/tmp/x`): a zone
60
+ * or locale value that is a path makes `date` open that file.
61
+ */
62
+ /** Assignments a display `date` may carry: the zone, and the locale it prints in. */
63
+ export const DATE_ENV_NAMES = ["TZ", "LANG", "LANGUAGE", "LC_ALL", "LC_TIME"];
64
+ /** Characters the shell may expand into more words, or into other words. */
65
+ const UNREADABLE_WORD = /[$`*?[\]{}]/u;
66
+ /** Long options that take no value, by exact spelling. */
67
+ const LONG_BARE = [
68
+ "--utc",
69
+ "--universal",
70
+ "--rfc-2822",
71
+ "--rfc-email",
72
+ "--iso-8601",
73
+ "--debug",
74
+ "--resolution",
75
+ "--help",
76
+ "--version",
77
+ ];
78
+ /**
79
+ * Short words that take no value, by exact spelling. Clusters are admitted
80
+ * only as listed here: no general cluster parsing, so a letter this file does
81
+ * not know can never ride inside one.
82
+ */
83
+ const SHORT_BARE = ["-u", "-R", "-h", "-V", "-I", "-uR", "-Ru"];
84
+ /** The `-I` / `--iso-8601` precisions, attached (`-Iseconds`, `--iso-8601=ns`). */
85
+ const ISO_PRECISIONS = ["date", "hours", "minutes", "seconds", "ns"];
86
+ /** The `--rfc-3339` precisions. */
87
+ const RFC3339_PRECISIONS = ["date", "seconds", "ns"];
88
+ /** Words that take the NEXT word as a date string. */
89
+ const DATE_VALUE_WORDS = ["-d", "-ud", "--date"];
90
+ /**
91
+ * A tz database name (`Asia/Kolkata`, `Etc/GMT+5`, `UTC`), optionally behind
92
+ * the POSIX `:`. Every segment is a name: no leading `/`, no `.` anywhere, so
93
+ * neither an absolute path nor a `..` climb out of the zoneinfo directory.
94
+ */
95
+ const ZONE_NAME = /^:?[A-Za-z_][A-Za-z0-9_+-]*(?:\/[A-Za-z0-9_+-]+)*$/u;
96
+ /**
97
+ * A POSIX TZ rule with no transition dates (`IST-5:30`, `EST5EDT`, `<+0530>-5:30`).
98
+ * A rule never names a file.
99
+ */
100
+ const POSIX_ZONE = /^(?:[A-Za-z]{3,}|<[A-Za-z0-9+-]{3,}>)[+-]?\d{1,2}(?::\d{2}){0,2}(?:(?:[A-Za-z]{3,}|<[A-Za-z0-9+-]{3,}>)(?:[+-]?\d{1,2}(?::\d{2}){0,2})?)?$/u;
101
+ /** A locale name (`C`, `C.UTF-8`, `en_US.UTF-8`, `en:fr`), never a path. */
102
+ const LOCALE_VALUE = /^[A-Za-z0-9_@.:-]*$/u;
103
+ /** Is this a zone value that names no file outside the zone database? */
104
+ export function isZoneValue(value) {
105
+ if (value === "")
106
+ return true;
107
+ if (value.includes(".."))
108
+ return false;
109
+ return ZONE_NAME.test(value) || POSIX_ZONE.test(value);
110
+ }
111
+ /**
112
+ * May this `NAME=value` word stand in front of a display `date`?
113
+ *
114
+ * Only the zone and locale names, and only with a value that cannot name a
115
+ * file: a zone outside the database or a locale that is a path makes `date`
116
+ * open whatever the value names.
117
+ */
118
+ export function isDateAssignment(word) {
119
+ const equals = word.indexOf("=");
120
+ if (equals <= 0)
121
+ return false;
122
+ const name = word.slice(0, equals);
123
+ const value = word.slice(equals + 1);
124
+ if (!DATE_ENV_NAMES.includes(name))
125
+ return false;
126
+ if (UNREADABLE_WORD.test(value) || value.includes("~"))
127
+ return false;
128
+ if (name === "TZ")
129
+ return isZoneValue(value);
130
+ return !value.includes("..") && LOCALE_VALUE.test(value);
131
+ }
132
+ /**
133
+ * Does a `-d` string carry only zones that name no file?
134
+ *
135
+ * GNU (and the parser uutils uses) accept a leading `TZ="Zone"` inside the
136
+ * date string, and resolve it as the variable would be resolved.
137
+ */
138
+ function isDateString(value) {
139
+ // Case-insensitive (refutation S2): GNU's prefix is `TZ=` exactly, but a
140
+ // parser that folds case would read `tz="/etc/x"` as a zone path too.
141
+ const embedded = /TZ\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S*))/giu;
142
+ for (let match = embedded.exec(value); match !== null; match = embedded.exec(value)) {
143
+ const zone = match[1] ?? match[2] ?? match[3] ?? "";
144
+ if (!isZoneValue(zone))
145
+ return false;
146
+ }
147
+ return true;
148
+ }
149
+ /** A required value: present, not flag-shaped, and readable as a date string. */
150
+ function isRequiredValue(value) {
151
+ return value !== undefined && !value.startsWith("-") && isDateString(value);
152
+ }
153
+ /**
154
+ * Is this `date` argv a display form? `args` is the words after the binary,
155
+ * quotes already removed; `assignments` the `NAME=value` words in front of it.
156
+ *
157
+ * A strict allow-grammar: every word must be one of the exact spellings below,
158
+ * a value in a position one of them opens, or the single `+FORMAT` operand.
159
+ * Anything else (a cluster not listed, an abbreviation, `--`, an `=` joined
160
+ * to a short flag) answers `false`.
161
+ */
162
+ export function isDateDisplay(args, assignments = []) {
163
+ if (!assignments.every((word) => isDateAssignment(word)))
164
+ return false;
165
+ if (args.some((arg) => UNREADABLE_WORD.test(arg)))
166
+ return false;
167
+ const seen = new Set();
168
+ let operands = 0;
169
+ for (let index = 0; index < args.length; index += 1) {
170
+ const arg = args[index];
171
+ // A flag word given twice: clap (uutils) refuses it, getopt takes the last.
172
+ if (arg.startsWith("-")) {
173
+ if (seen.has(arg))
174
+ return false;
175
+ seen.add(arg);
176
+ }
177
+ if (LONG_BARE.includes(arg) || SHORT_BARE.includes(arg))
178
+ continue;
179
+ if (arg.startsWith("-I") && ISO_PRECISIONS.includes(arg.slice(2)))
180
+ continue;
181
+ if (arg.startsWith("--iso-8601=") && ISO_PRECISIONS.includes(arg.slice("--iso-8601=".length)))
182
+ continue;
183
+ if (arg.startsWith("--rfc-3339=") && RFC3339_PRECISIONS.includes(arg.slice("--rfc-3339=".length)))
184
+ continue;
185
+ if (arg === "--rfc-3339") {
186
+ index += 1;
187
+ if (!RFC3339_PRECISIONS.includes(args[index] ?? ""))
188
+ return false;
189
+ continue;
190
+ }
191
+ if (arg.startsWith("--date=")) {
192
+ if (!isDateString(arg.slice("--date=".length)))
193
+ return false;
194
+ continue;
195
+ }
196
+ if (DATE_VALUE_WORDS.includes(arg)) {
197
+ index += 1;
198
+ if (!isRequiredValue(args[index]))
199
+ return false;
200
+ continue;
201
+ }
202
+ // An operand: exactly one, and only an output format. Anything else is a
203
+ // flag this grammar does not list, or a clock setting.
204
+ if (!arg.startsWith("+"))
205
+ return false;
206
+ operands += 1;
207
+ if (operands > 1)
208
+ return false;
209
+ }
210
+ return true;
211
+ }
212
+ //# sourceMappingURL=date-argv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-argv.js","sourceRoot":"","sources":["../../../src/core/date-argv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,qFAAqF;AACrF,MAAM,CAAC,MAAM,cAAc,GAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEjG,4EAA4E;AAC5E,MAAM,eAAe,GAAG,cAAc,CAAC;AAEvC,0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GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAAE,SAAS;QAC5G,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;YACzB,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBAAE,OAAO,KAAK,CAAC;YAClE,SAAS;QACX,CAAC;QACD,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC7D,SAAS;QACX,CAAC;QACD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAChD,SAAS;QACX,CAAC;QACD,yEAAyE;QACzE,uDAAuD;QACvD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACvC,QAAQ,IAAI,CAAC,CAAC;QACd,IAAI,QAAQ,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -144,6 +144,7 @@ export const READ_TARGET_SHAPES = {
144
144
  ls: "all",
145
145
  md5sum: "all",
146
146
  openssl: "after-pattern",
147
+ paste: "all",
147
148
  rg: "after-pattern",
148
149
  sed: "after-pattern",
149
150
  sha256sum: "all",
@@ -1 +1 @@
1
- {"version":3,"file":"read-scope.js","sourceRoot":"","sources":["../../../src/core/read-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH;;;;;;;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,CAAC;IACjD,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,YAAY,CAAC;IAC3D,OAAO,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The system-information readers' safe forms (APRV-508).
3
+ *
4
+ * `uptime`, `whoami`, `hostname`, `df`, `free`, `seq` and `paste` each print
5
+ * something and change nothing in the forms below, and some of them change
6
+ * something in forms that look almost the same: `hostname NAME` and `hostname
7
+ * -F FILE` SET the host name, `free -s N` loops forever, `uptime FILE` reads a
8
+ * utmp file. So each binary gets a STRICT allow-grammar rather than a seat in
9
+ * the read table:
10
+ *
11
+ * - every flag is matched by its exact spelling. No abbreviation (getopt and
12
+ * clap both accept a unique prefix of a long option), no cluster except the
13
+ * ones a table below lists word for word, no `=` joined to a short flag;
14
+ * - `--` is never accepted;
15
+ * - an operand is accepted only where the binary's grammar names one, and
16
+ * only in the shape it names (a number for `seq`, a file for `paste`);
17
+ * - a word carrying `$`, a backtick, a glob or a brace is never accepted,
18
+ * since the shell may expand it into words this grammar never saw;
19
+ * - nothing else. An argv this file does not recognise answers `false`, and
20
+ * the classifier row does not match, so the command keeps the
21
+ * `unclassified` refusal it had before the row existed.
22
+ *
23
+ * Two implementations are read at once: GNU (coreutils, procps, net-tools
24
+ * `hostname`) and uutils coreutils 0.10, which the hosted boxes run. Where a
25
+ * spelling exists in one and not the other, the other errors out on it, which
26
+ * is a refusal by the tool rather than a different act.
27
+ */
28
+ /** `uptime` and `whoami`: nothing, or `--help` / `--version`. */
29
+ export declare function isBareInfo(args: readonly string[]): boolean;
30
+ export declare function isHostnameDisplay(args: readonly string[]): boolean;
31
+ export declare function isDfDisplay(args: readonly string[]): boolean;
32
+ export declare function isFreeDisplay(args: readonly string[]): boolean;
33
+ /**
34
+ * The most values an admitted `seq` prints (refutation S4). `seq 1e18` is a
35
+ * read in the sense that it changes nothing, but it holds the turn the way
36
+ * `free -s` does, so a range past this is not admitted.
37
+ */
38
+ export declare const SEQ_MAX_VALUES = 100000;
39
+ /**
40
+ * `seq`: one to three numbers, with `-w`/`--equal-width`, `-s SEP` /
41
+ * `--separator=SEP` and `-f FMT` / `--format=FMT`. A separate-word value is
42
+ * the next word; the attached short spellings (`-s,`) are not in the grammar.
43
+ * Every flag comes BEFORE the first number: uutils reads a word after a number
44
+ * as another number (`seq 1 -w` is an error there and a flag to GNU), and the
45
+ * grammar takes the reading both agree on.
46
+ */
47
+ export declare function isSeqDisplay(args: readonly string[]): boolean;
48
+ export declare function isPasteRead(args: readonly string[]): boolean;
@@ -0,0 +1,340 @@
1
+ /**
2
+ * The system-information readers' safe forms (APRV-508).
3
+ *
4
+ * `uptime`, `whoami`, `hostname`, `df`, `free`, `seq` and `paste` each print
5
+ * something and change nothing in the forms below, and some of them change
6
+ * something in forms that look almost the same: `hostname NAME` and `hostname
7
+ * -F FILE` SET the host name, `free -s N` loops forever, `uptime FILE` reads a
8
+ * utmp file. So each binary gets a STRICT allow-grammar rather than a seat in
9
+ * the read table:
10
+ *
11
+ * - every flag is matched by its exact spelling. No abbreviation (getopt and
12
+ * clap both accept a unique prefix of a long option), no cluster except the
13
+ * ones a table below lists word for word, no `=` joined to a short flag;
14
+ * - `--` is never accepted;
15
+ * - an operand is accepted only where the binary's grammar names one, and
16
+ * only in the shape it names (a number for `seq`, a file for `paste`);
17
+ * - a word carrying `$`, a backtick, a glob or a brace is never accepted,
18
+ * since the shell may expand it into words this grammar never saw;
19
+ * - nothing else. An argv this file does not recognise answers `false`, and
20
+ * the classifier row does not match, so the command keeps the
21
+ * `unclassified` refusal it had before the row existed.
22
+ *
23
+ * Two implementations are read at once: GNU (coreutils, procps, net-tools
24
+ * `hostname`) and uutils coreutils 0.10, which the hosted boxes run. Where a
25
+ * spelling exists in one and not the other, the other errors out on it, which
26
+ * is a refusal by the tool rather than a different act.
27
+ */
28
+ /**
29
+ * Characters the shell may expand into more words, or into other words. A
30
+ * leading `~` is not among them: it expands to one path and never splits, and
31
+ * the read scope already judges a `~` path as one it cannot place.
32
+ */
33
+ const UNREADABLE_WORD = /[$`*?[\]{}]/u;
34
+ /** No word of this argv is one the shell may expand. */
35
+ function literal(args) {
36
+ return !args.some((arg) => UNREADABLE_WORD.test(arg));
37
+ }
38
+ /**
39
+ * The option each flag word sets, so that two spellings of one option count
40
+ * as a repeat (`-s --serial`, `-h --human-readable`, `-h -hT`). A word not in
41
+ * the map is its own option.
42
+ */
43
+ const SAME_OPTION = {
44
+ "--human-readable": ["-h"],
45
+ "--si": ["-H"],
46
+ "--print-type": ["-T"],
47
+ "--inodes": ["-i"],
48
+ "--all": ["-a"],
49
+ "--local": ["-l"],
50
+ "--portability": ["-P"],
51
+ "-hT": ["-h", "-T"],
52
+ "-Th": ["-h", "-T"],
53
+ "-hi": ["-h", "-i"],
54
+ "-ih": ["-h", "-i"],
55
+ "-hl": ["-h", "-l"],
56
+ "-lh": ["-h", "-l"],
57
+ "--bytes": ["-b"],
58
+ "--kibi": ["-k"],
59
+ "--mebi": ["-m"],
60
+ "--gibi": ["-g"],
61
+ "--human": ["-h"],
62
+ "--lohi": ["-l"],
63
+ "--total": ["-t"],
64
+ "--wide": ["-w"],
65
+ "--committed": ["-v"],
66
+ "-ht": ["-h", "-t"],
67
+ "-th": ["-h", "-t"],
68
+ "-hw": ["-h", "-w"],
69
+ "-wh": ["-h", "-w"],
70
+ "--equal-width": ["-w"],
71
+ "--separator": ["-s"],
72
+ "--format": ["-f"],
73
+ "--serial": ["-s"],
74
+ "--zero-terminated": ["-z"],
75
+ };
76
+ /**
77
+ * No option is given twice, in any spelling. clap (uutils) refuses a repeated
78
+ * option where getopt takes the last one, so the grammar admits neither.
79
+ * `-dX` / `--delimiters=X` and `--separator=X` / `--format=X` count by name.
80
+ */
81
+ function noRepeatedFlag(args, valueWords = []) {
82
+ const seen = new Set();
83
+ for (let index = 0; index < args.length; index += 1) {
84
+ const arg = args[index];
85
+ if (!arg.startsWith("-") || arg === "-" || /^-[\d.]/u.test(arg))
86
+ continue;
87
+ let name = arg;
88
+ if (arg.startsWith("--delimiters=") || (arg.startsWith("-d") && !arg.startsWith("--")))
89
+ name = "-d";
90
+ else if (arg.startsWith("--separator="))
91
+ name = "-s";
92
+ else if (arg.startsWith("--format="))
93
+ name = "-f";
94
+ for (const option of SAME_OPTION[name] ?? [name]) {
95
+ if (seen.has(option))
96
+ return false;
97
+ seen.add(option);
98
+ }
99
+ // A separate-word value is not a flag, even when it looks like one.
100
+ if (valueWords.includes(arg))
101
+ index += 1;
102
+ }
103
+ return true;
104
+ }
105
+ /** `--help` or `--version`, alone. */
106
+ function isHelpOrVersion(args) {
107
+ return args.length === 1 && (args[0] === "--help" || args[0] === "--version");
108
+ }
109
+ /** `uptime` and `whoami`: nothing, or `--help` / `--version`. */
110
+ export function isBareInfo(args) {
111
+ return args.length === 0 || isHelpOrVersion(args);
112
+ }
113
+ /**
114
+ * `hostname`: nothing, or ONE display flag. Any operand sets the host name,
115
+ * and `-F`/`--file`/`-b`/`--boot` set it from a file or at boot, so none of
116
+ * them is in the list.
117
+ */
118
+ const HOSTNAME_FLAGS = [
119
+ "-s",
120
+ "--short",
121
+ "-f",
122
+ "--fqdn",
123
+ "--long",
124
+ "-d",
125
+ "--domain",
126
+ "-i",
127
+ "--ip-address",
128
+ "-I",
129
+ "--all-ip-addresses",
130
+ "--help",
131
+ "--version",
132
+ ];
133
+ export function isHostnameDisplay(args) {
134
+ if (args.length === 0)
135
+ return true;
136
+ return args.length === 1 && HOSTNAME_FLAGS.includes(args[0]);
137
+ }
138
+ /**
139
+ * `df`: display flags only. A path operand would be a read the read scope
140
+ * judges, and the agents asking need the mount table, so operands are not in
141
+ * the grammar. `--output` and the type filters are left out with them.
142
+ */
143
+ const DF_FLAGS = [
144
+ "-h",
145
+ "--human-readable",
146
+ "-H",
147
+ "--si",
148
+ "-k",
149
+ "-T",
150
+ "--print-type",
151
+ "-i",
152
+ "--inodes",
153
+ "-a",
154
+ "--all",
155
+ "-l",
156
+ "--local",
157
+ "-P",
158
+ "--portability",
159
+ "--total",
160
+ "--help",
161
+ "--version",
162
+ // The clusters, by exact spelling.
163
+ "-hT",
164
+ "-Th",
165
+ "-hi",
166
+ "-ih",
167
+ "-hl",
168
+ "-lh",
169
+ ];
170
+ export function isDfDisplay(args) {
171
+ return literal(args) && noRepeatedFlag(args) && args.every((arg) => DF_FLAGS.includes(arg));
172
+ }
173
+ /**
174
+ * `free`: display flags only. `-s`/`--seconds` and `-c`/`--count` repeat the
175
+ * report on a timer, which holds the turn rather than reading anything, and
176
+ * stay out.
177
+ */
178
+ const FREE_FLAGS = [
179
+ "-b",
180
+ "--bytes",
181
+ "-k",
182
+ "--kibi",
183
+ "--kilo",
184
+ "-m",
185
+ "--mebi",
186
+ "--mega",
187
+ "-g",
188
+ "--gibi",
189
+ "--giga",
190
+ "-h",
191
+ "--human",
192
+ "--si",
193
+ "-l",
194
+ "--lohi",
195
+ "-t",
196
+ "--total",
197
+ "-w",
198
+ "--wide",
199
+ "-v",
200
+ "--committed",
201
+ "--help",
202
+ "--version",
203
+ "-ht",
204
+ "-th",
205
+ "-hw",
206
+ "-wh",
207
+ ];
208
+ export function isFreeDisplay(args) {
209
+ return literal(args) && noRepeatedFlag(args) && args.every((arg) => FREE_FLAGS.includes(arg));
210
+ }
211
+ /** A decimal number, signed or not, with an optional exponent. No hex, `inf` or `nan`. */
212
+ const SEQ_NUMBER = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/u;
213
+ /**
214
+ * The most values an admitted `seq` prints (refutation S4). `seq 1e18` is a
215
+ * read in the sense that it changes nothing, but it holds the turn the way
216
+ * `free -s` does, so a range past this is not admitted.
217
+ */
218
+ export const SEQ_MAX_VALUES = 100_000;
219
+ /**
220
+ * Can a double hold this number exactly enough to count with? (Recheck S-R2.)
221
+ * GNU and uutils count digit strings exactly, so a range narrower than half a
222
+ * ULP of its ends (`seq 1e30-ish 1e30-ish+5e13`) reads as one value to a
223
+ * double and prints fifty trillion. No more than 15 significant digits, and no
224
+ * magnitude above 2^53, keeps every admitted operand exact enough.
225
+ */
226
+ function isCountable(word) {
227
+ const mantissa = word.replace(/^[-+]/u, "").replace(/[eE].*$/u, "").replace(".", "");
228
+ const significant = mantissa.replace(/^0+/u, "");
229
+ if (significant.length > 15)
230
+ return false;
231
+ return Math.abs(Number(word)) <= 2 ** 53;
232
+ }
233
+ /** How many values `seq FIRST [INCREMENT] LAST` prints; Infinity when it never ends. */
234
+ function seqCount(numbers) {
235
+ const [first, increment, last] = numbers.length === 1
236
+ ? [1, 1, numbers[0]]
237
+ : numbers.length === 2
238
+ ? [numbers[0], 1, numbers[1]]
239
+ : [numbers[0], numbers[1], numbers[2]];
240
+ if (![first, increment, last].every((n) => Number.isFinite(n)))
241
+ return Infinity;
242
+ if (increment === 0)
243
+ return Infinity;
244
+ const steps = Math.floor((last - first) / increment);
245
+ return steps < 0 ? 0 : steps + 1;
246
+ }
247
+ /** One floating-point directive, `%%` escapes around it, nothing else. */
248
+ const SEQ_FORMAT = /^(?:[^%]|%%)*%[-+ #0]*\d*(?:\.\d+)?[eEfFgG](?:[^%]|%%)*$/u;
249
+ /** A separator: any literal text that does not look like a flag. */
250
+ function isSeqSeparator(value) {
251
+ return value !== undefined && !value.startsWith("-");
252
+ }
253
+ /**
254
+ * `seq`: one to three numbers, with `-w`/`--equal-width`, `-s SEP` /
255
+ * `--separator=SEP` and `-f FMT` / `--format=FMT`. A separate-word value is
256
+ * the next word; the attached short spellings (`-s,`) are not in the grammar.
257
+ * Every flag comes BEFORE the first number: uutils reads a word after a number
258
+ * as another number (`seq 1 -w` is an error there and a flag to GNU), and the
259
+ * grammar takes the reading both agree on.
260
+ */
261
+ export function isSeqDisplay(args) {
262
+ if (!literal(args) || !noRepeatedFlag(args, ["-s", "--separator", "-f", "--format"]))
263
+ return false;
264
+ if (isHelpOrVersion(args))
265
+ return true;
266
+ let numbers = 0;
267
+ for (let index = 0; index < args.length; index += 1) {
268
+ const arg = args[index];
269
+ if (numbers > 0) {
270
+ if (!SEQ_NUMBER.test(arg))
271
+ return false;
272
+ numbers += 1;
273
+ continue;
274
+ }
275
+ if (arg === "-w" || arg === "--equal-width")
276
+ continue;
277
+ if (arg === "-s" || arg === "--separator") {
278
+ index += 1;
279
+ if (!isSeqSeparator(args[index]))
280
+ return false;
281
+ continue;
282
+ }
283
+ if (arg.startsWith("--separator="))
284
+ continue;
285
+ if (arg === "-f" || arg === "--format") {
286
+ index += 1;
287
+ // A flag-shaped value is the value to getopt and the next flag to clap.
288
+ const value = args[index] ?? "";
289
+ if (value.startsWith("-") || !SEQ_FORMAT.test(value))
290
+ return false;
291
+ continue;
292
+ }
293
+ if (arg.startsWith("--format=")) {
294
+ if (!SEQ_FORMAT.test(arg.slice("--format=".length)))
295
+ return false;
296
+ continue;
297
+ }
298
+ if (!SEQ_NUMBER.test(arg))
299
+ return false;
300
+ numbers += 1;
301
+ }
302
+ // GNU and uutils both refuse a format beside equal width.
303
+ const width = args.includes("-w") || args.includes("--equal-width");
304
+ const format = args.some((arg) => arg === "-f" || arg === "--format" || arg.startsWith("--format="));
305
+ if (width && format)
306
+ return false;
307
+ if (numbers < 1 || numbers > 3)
308
+ return false;
309
+ const operands = args.slice(args.length - numbers);
310
+ if (!operands.every((word) => isCountable(word)))
311
+ return false;
312
+ return seqCount(operands.map(Number)) <= SEQ_MAX_VALUES;
313
+ }
314
+ /**
315
+ * `paste`: files (or `-`, standard input) with `-s`/`--serial`,
316
+ * `-z`/`--zero-terminated`, and the delimiter list ATTACHED (`-d,`,
317
+ * `--delimiters=,`). Attached, so that every positional is a file: the read
318
+ * scope takes paste's operands exactly as it takes `cat`'s (`READ_TARGET_SHAPES`
319
+ * in read-scope.ts), and a delimiter in its own word would be taken for one.
320
+ */
321
+ const PASTE_FLAGS = ["-s", "--serial", "-z", "--zero-terminated", "--help", "--version"];
322
+ export function isPasteRead(args) {
323
+ if (!literal(args) || !noRepeatedFlag(args))
324
+ return false;
325
+ for (const arg of args) {
326
+ if (PASTE_FLAGS.includes(arg))
327
+ continue;
328
+ if (arg.startsWith("--delimiters="))
329
+ continue;
330
+ if (arg.startsWith("-d") && arg.length > 2)
331
+ continue;
332
+ // A file, or `-` for standard input. Every other flag-shaped word is not
333
+ // in the grammar (`--`, `-d` with a separate value, abbreviations).
334
+ if (arg === "-" || !arg.startsWith("-"))
335
+ continue;
336
+ return false;
337
+ }
338
+ return true;
339
+ }
340
+ //# sourceMappingURL=sysinfo-argv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sysinfo-argv.js","sourceRoot":"","sources":["../../../src/core/sysinfo-argv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;GAIG;AACH,MAAM,eAAe,GAAG,cAAc,CAAC;AAEvC,wDAAwD;AACxD,SAAS,OAAO,CAAC,IAAuB;IACtC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,WAAW,GAAgD;IAC/D,kBAAkB,EAAE,CAAC,IAAI,CAAC;IAC1B,MAAM,EAAE,CAAC,IAAI,CAAC;IACd,cAAc,EAAE,CAAC,IAAI,CAAC;IACtB,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,SAAS,EAAE,CAAC,IAAI,CAAC;IACjB,eAAe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