shell-dsl 0.0.8 → 0.0.9

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "shell-dsl",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "commonjs"
5
5
  }
@@ -36,9 +36,11 @@ function parseSubstitution(script) {
36
36
  const match = script.match(/^s(.)(.+?)\1(.*?)\1([gi]*)$/);
37
37
  if (!match)
38
38
  return null;
39
- const [, , patternStr, replacement, flags] = match;
39
+ const [, , rawPattern, rawReplacement, flags] = match;
40
40
  const globalFlag = flags.includes("g");
41
41
  const caseInsensitive = flags.includes("i");
42
+ const patternStr = rawPattern.replace(/\\\(/g, "(").replace(/\\\)/g, ")");
43
+ const replacement = rawReplacement.replace(/\\([0-9])/g, "\x00BACKREF$1\x00").replace(/\$/g, "$$$$").replace(/\x00BACKREF([0-9])\x00/g, "$$$1");
42
44
  try {
43
45
  const regexFlags = caseInsensitive ? "i" : "";
44
46
  return {
@@ -97,9 +99,48 @@ function parseCommand(script) {
97
99
  return subCmd;
98
100
  return null;
99
101
  }
102
+ function splitScriptParts(script) {
103
+ const parts = [];
104
+ let i = 0;
105
+ let current = "";
106
+ while (i < script.length) {
107
+ if (script[i] === "s" && i + 1 < script.length) {
108
+ const delim = script[i + 1];
109
+ let j = i + 2;
110
+ let delimCount = 0;
111
+ while (j < script.length && delimCount < 2) {
112
+ if (script[j] === "\\") {
113
+ j += 2;
114
+ continue;
115
+ }
116
+ if (script[j] === delim)
117
+ delimCount++;
118
+ j++;
119
+ }
120
+ while (j < script.length && /[gi]/.test(script[j]))
121
+ j++;
122
+ current += script.slice(i, j);
123
+ i = j;
124
+ } else if (script[i] === ";") {
125
+ const trimmed2 = current.trim();
126
+ if (trimmed2)
127
+ parts.push(trimmed2);
128
+ current = "";
129
+ i++;
130
+ } else {
131
+ current += script[i];
132
+ i++;
133
+ }
134
+ }
135
+ const trimmed = current.trim();
136
+ if (trimmed)
137
+ parts.push(trimmed);
138
+ return parts;
139
+ }
100
140
  function parseArgs(args) {
101
141
  const options = {
102
142
  suppressOutput: false,
143
+ inPlace: false,
103
144
  commands: []
104
145
  };
105
146
  const files = [];
@@ -111,6 +152,11 @@ function parseArgs(args) {
111
152
  i++;
112
153
  continue;
113
154
  }
155
+ if (arg === "-i") {
156
+ options.inPlace = true;
157
+ i++;
158
+ continue;
159
+ }
114
160
  if (arg === "-e" && args[i + 1] !== undefined) {
115
161
  const cmd = parseCommand(args[i + 1]);
116
162
  if (cmd) {
@@ -121,9 +167,12 @@ function parseArgs(args) {
121
167
  }
122
168
  if (!arg.startsWith("-")) {
123
169
  if (options.commands.length === 0) {
124
- const cmd = parseCommand(arg);
125
- if (cmd) {
126
- options.commands.push(cmd);
170
+ const parts = splitScriptParts(arg);
171
+ for (const part of parts) {
172
+ const cmd = parseCommand(part);
173
+ if (cmd) {
174
+ options.commands.push(cmd);
175
+ }
127
176
  }
128
177
  } else {
129
178
  files.push(arg);
@@ -198,6 +247,34 @@ var sed = async (ctx) => {
198
247
  if (files.length === 0) {
199
248
  const content = await ctx.stdin.text();
200
249
  await processContent(content);
250
+ } else if (options.inPlace) {
251
+ for (const file of files) {
252
+ try {
253
+ const path = ctx.fs.resolve(ctx.cwd, file);
254
+ const content = await ctx.fs.readFile(path);
255
+ const lines = content.toString().split(`
256
+ `);
257
+ if (lines.length > 0 && lines[lines.length - 1] === "") {
258
+ lines.pop();
259
+ }
260
+ const outputLines = [];
261
+ for (const line of lines) {
262
+ const { output } = processLine(line, options.commands, options.suppressOutput);
263
+ if (output !== null) {
264
+ outputLines.push(output);
265
+ }
266
+ }
267
+ const result = outputLines.length > 0 ? outputLines.join(`
268
+ `) + `
269
+ ` : "";
270
+ await ctx.fs.writeFile(path, result);
271
+ } catch (err) {
272
+ const message = err instanceof Error ? err.message : String(err);
273
+ await ctx.stderr.writeText(`sed: ${file}: ${message}
274
+ `);
275
+ return 1;
276
+ }
277
+ }
201
278
  } else {
202
279
  for (const file of files) {
203
280
  try {
@@ -215,4 +292,4 @@ var sed = async (ctx) => {
215
292
  return 0;
216
293
  };
217
294
 
218
- //# debugId=DDBBCFEFFAE5FE0A64756E2164756E21
295
+ //# debugId=C4AEC38FC548256C64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/commands/sed/sed.ts"],
4
4
  "sourcesContent": [
5
- "import type { Command } from \"../../types.cjs\";\n\ninterface SedCommand {\n type: \"s\" | \"d\" | \"p\";\n addressPattern?: RegExp;\n pattern?: RegExp;\n replacement?: string;\n globalFlag: boolean;\n printFlag: boolean;\n}\n\ninterface SedOptions {\n suppressOutput: boolean; // -n\n commands: SedCommand[];\n}\n\nfunction parseSubstitution(script: string): SedCommand | null {\n // Match s/pattern/replacement/flags format\n // Support different delimiters (first char after 's')\n const match = script.match(/^s(.)(.+?)\\1(.*?)\\1([gi]*)$/);\n if (!match) return null;\n\n const [, , patternStr, replacement, flags] = match;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n\n try {\n const regexFlags = caseInsensitive ? \"i\" : \"\";\n return {\n type: \"s\",\n pattern: new RegExp(patternStr!, regexFlags),\n replacement: replacement!,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n}\n\nfunction parseCommand(script: string): SedCommand | null {\n const trimmed = script.trim();\n\n // Check for address pattern (e.g., /foo/d or /foo/p)\n const addressMatch = trimmed.match(/^\\/(.+?)\\/([dp])$/);\n if (addressMatch) {\n const [, addressPatternStr, cmd] = addressMatch;\n try {\n return {\n type: cmd as \"d\" | \"p\",\n addressPattern: new RegExp(addressPatternStr!),\n globalFlag: false,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Simple d or p command (applies to all lines)\n if (trimmed === \"d\") {\n return { type: \"d\", globalFlag: false, printFlag: false };\n }\n if (trimmed === \"p\") {\n return { type: \"p\", globalFlag: false, printFlag: false };\n }\n\n // Address pattern with substitution: /pattern/s/old/new/flags\n const addressSubMatch = trimmed.match(/^\\/(.+?)\\/s(.)(.+?)\\2(.*?)\\2([gi]*)$/);\n if (addressSubMatch) {\n const [, addressPatternStr, , patternStr, replacement, flags] = addressSubMatch;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n try {\n return {\n type: \"s\",\n addressPattern: new RegExp(addressPatternStr!),\n pattern: new RegExp(patternStr!, caseInsensitive ? \"i\" : \"\"),\n replacement: replacement!,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Substitution command\n const subCmd = parseSubstitution(trimmed);\n if (subCmd) return subCmd;\n\n return null;\n}\n\nfunction parseArgs(args: string[]): { options: SedOptions; files: string[] } {\n const options: SedOptions = {\n suppressOutput: false,\n commands: [],\n };\n const files: string[] = [];\n\n let i = 0;\n while (i < args.length) {\n const arg = args[i]!;\n\n if (arg === \"-n\") {\n options.suppressOutput = true;\n i++;\n continue;\n }\n\n if (arg === \"-e\" && args[i + 1] !== undefined) {\n const cmd = parseCommand(args[i + 1]!);\n if (cmd) {\n options.commands.push(cmd);\n }\n i += 2;\n continue;\n }\n\n // Non-flag argument: either a script or a file\n if (!arg.startsWith(\"-\")) {\n if (options.commands.length === 0) {\n // First non-flag is the script\n const cmd = parseCommand(arg);\n if (cmd) {\n options.commands.push(cmd);\n }\n } else {\n // Subsequent non-flags are files\n files.push(arg);\n }\n }\n i++;\n }\n\n return { options, files };\n}\n\nfunction applySubstitution(line: string, cmd: SedCommand): string {\n if (!cmd.pattern) return line;\n\n if (cmd.globalFlag) {\n return line.replace(new RegExp(cmd.pattern.source, cmd.pattern.flags + \"g\"), cmd.replacement!);\n } else {\n return line.replace(cmd.pattern, cmd.replacement!);\n }\n}\n\nfunction processLine(\n line: string,\n commands: SedCommand[],\n suppressOutput: boolean\n): { output: string | null; deleted: boolean } {\n let currentLine = line;\n let deleted = false;\n let printed = false;\n\n for (const cmd of commands) {\n // Check address pattern first\n if (cmd.addressPattern && !cmd.addressPattern.test(currentLine)) {\n continue; // Skip this command if address doesn't match\n }\n\n switch (cmd.type) {\n case \"s\":\n currentLine = applySubstitution(currentLine, cmd);\n break;\n case \"d\":\n deleted = true;\n return { output: null, deleted: true };\n case \"p\":\n printed = true;\n break;\n }\n }\n\n if (deleted) {\n return { output: null, deleted: true };\n }\n\n if (suppressOutput) {\n // With -n, only output if explicitly printed\n return { output: printed ? currentLine : null, deleted: false };\n }\n\n // Without -n, always output (plus extra if printed)\n if (printed) {\n return { output: currentLine + \"\\n\" + currentLine, deleted: false };\n }\n return { output: currentLine, deleted: false };\n}\n\nexport const sed: Command = async (ctx) => {\n const { options, files } = parseArgs(ctx.args);\n\n if (options.commands.length === 0) {\n await ctx.stderr.writeText(\"sed: missing script\\n\");\n return 1;\n }\n\n const processContent = async (content: string): Promise<void> => {\n const lines = content.split(\"\\n\");\n // Handle trailing newline\n if (lines.length > 0 && lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n\n for (const line of lines) {\n const { output } = processLine(line, options.commands, options.suppressOutput);\n if (output !== null) {\n await ctx.stdout.writeText(output + \"\\n\");\n }\n }\n };\n\n if (files.length === 0) {\n // Read from stdin\n const content = await ctx.stdin.text();\n await processContent(content);\n } else {\n // Read from files\n for (const file of files) {\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = await ctx.fs.readFile(path);\n await processContent(content.toString());\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`sed: ${file}: ${message}\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
5
+ "import type { Command } from \"../../types.cjs\";\n\ninterface SedCommand {\n type: \"s\" | \"d\" | \"p\";\n addressPattern?: RegExp;\n pattern?: RegExp;\n replacement?: string;\n globalFlag: boolean;\n printFlag: boolean;\n}\n\ninterface SedOptions {\n suppressOutput: boolean; // -n\n inPlace: boolean; // -i\n commands: SedCommand[];\n}\n\nfunction parseSubstitution(script: string): SedCommand | null {\n // Match s/pattern/replacement/flags format\n // Support different delimiters (first char after 's')\n const match = script.match(/^s(.)(.+?)\\1(.*?)\\1([gi]*)$/);\n if (!match) return null;\n\n const [, , rawPattern, rawReplacement, flags] = match;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n\n // Convert sed-style \\( \\) to JS ( ) for capture groups\n const patternStr = rawPattern!.replace(/\\\\\\(/g, \"(\").replace(/\\\\\\)/g, \")\");\n // Convert sed replacement to JS String.replace format:\n // 1. Mark backreferences \\1..\\9 with placeholders\n // 2. Escape $ so String.replace doesn't treat $$ as special\n // 3. Restore backreference placeholders as $1..$9\n const replacement = rawReplacement!\n .replace(/\\\\([0-9])/g, \"\\x00BACKREF$1\\x00\")\n .replace(/\\$/g, \"$$$$\")\n .replace(/\\x00BACKREF([0-9])\\x00/g, \"$$$1\");\n\n try {\n const regexFlags = caseInsensitive ? \"i\" : \"\";\n return {\n type: \"s\",\n pattern: new RegExp(patternStr, regexFlags),\n replacement,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n}\n\nfunction parseCommand(script: string): SedCommand | null {\n const trimmed = script.trim();\n\n // Check for address pattern (e.g., /foo/d or /foo/p)\n const addressMatch = trimmed.match(/^\\/(.+?)\\/([dp])$/);\n if (addressMatch) {\n const [, addressPatternStr, cmd] = addressMatch;\n try {\n return {\n type: cmd as \"d\" | \"p\",\n addressPattern: new RegExp(addressPatternStr!),\n globalFlag: false,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Simple d or p command (applies to all lines)\n if (trimmed === \"d\") {\n return { type: \"d\", globalFlag: false, printFlag: false };\n }\n if (trimmed === \"p\") {\n return { type: \"p\", globalFlag: false, printFlag: false };\n }\n\n // Address pattern with substitution: /pattern/s/old/new/flags\n const addressSubMatch = trimmed.match(/^\\/(.+?)\\/s(.)(.+?)\\2(.*?)\\2([gi]*)$/);\n if (addressSubMatch) {\n const [, addressPatternStr, , patternStr, replacement, flags] = addressSubMatch;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n try {\n return {\n type: \"s\",\n addressPattern: new RegExp(addressPatternStr!),\n pattern: new RegExp(patternStr!, caseInsensitive ? \"i\" : \"\"),\n replacement: replacement!,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Substitution command\n const subCmd = parseSubstitution(trimmed);\n if (subCmd) return subCmd;\n\n return null;\n}\n\nfunction splitScriptParts(script: string): string[] {\n // Split on ';' that are outside of s/// delimiters\n const parts: string[] = [];\n let i = 0;\n let current = \"\";\n while (i < script.length) {\n if (script[i] === \"s\" && i + 1 < script.length) {\n // Detect substitution command — consume s/pattern/replacement/flags\n const delim = script[i + 1]!;\n let j = i + 2;\n let delimCount = 0;\n while (j < script.length && delimCount < 2) {\n if (script[j] === \"\\\\\") {\n j += 2;\n continue;\n }\n if (script[j] === delim) delimCount++;\n j++;\n }\n // Consume trailing flags\n while (j < script.length && /[gi]/.test(script[j]!)) j++;\n current += script.slice(i, j);\n i = j;\n } else if (script[i] === \";\") {\n const trimmed = current.trim();\n if (trimmed) parts.push(trimmed);\n current = \"\";\n i++;\n } else {\n current += script[i];\n i++;\n }\n }\n const trimmed = current.trim();\n if (trimmed) parts.push(trimmed);\n return parts;\n}\n\nfunction parseArgs(args: string[]): { options: SedOptions; files: string[] } {\n const options: SedOptions = {\n suppressOutput: false,\n inPlace: false,\n commands: [],\n };\n const files: string[] = [];\n\n let i = 0;\n while (i < args.length) {\n const arg = args[i]!;\n\n if (arg === \"-n\") {\n options.suppressOutput = true;\n i++;\n continue;\n }\n\n if (arg === \"-i\") {\n options.inPlace = true;\n i++;\n continue;\n }\n\n if (arg === \"-e\" && args[i + 1] !== undefined) {\n const cmd = parseCommand(args[i + 1]!);\n if (cmd) {\n options.commands.push(cmd);\n }\n i += 2;\n continue;\n }\n\n // Non-flag argument: either a script or a file\n if (!arg.startsWith(\"-\")) {\n if (options.commands.length === 0) {\n // First non-flag is the script — may contain ;-separated commands\n const parts = splitScriptParts(arg);\n for (const part of parts) {\n const cmd = parseCommand(part);\n if (cmd) {\n options.commands.push(cmd);\n }\n }\n } else {\n // Subsequent non-flags are files\n files.push(arg);\n }\n }\n i++;\n }\n\n return { options, files };\n}\n\nfunction applySubstitution(line: string, cmd: SedCommand): string {\n if (!cmd.pattern) return line;\n\n if (cmd.globalFlag) {\n return line.replace(new RegExp(cmd.pattern.source, cmd.pattern.flags + \"g\"), cmd.replacement!);\n } else {\n return line.replace(cmd.pattern, cmd.replacement!);\n }\n}\n\nfunction processLine(\n line: string,\n commands: SedCommand[],\n suppressOutput: boolean\n): { output: string | null; deleted: boolean } {\n let currentLine = line;\n let deleted = false;\n let printed = false;\n\n for (const cmd of commands) {\n // Check address pattern first\n if (cmd.addressPattern && !cmd.addressPattern.test(currentLine)) {\n continue; // Skip this command if address doesn't match\n }\n\n switch (cmd.type) {\n case \"s\":\n currentLine = applySubstitution(currentLine, cmd);\n break;\n case \"d\":\n deleted = true;\n return { output: null, deleted: true };\n case \"p\":\n printed = true;\n break;\n }\n }\n\n if (deleted) {\n return { output: null, deleted: true };\n }\n\n if (suppressOutput) {\n // With -n, only output if explicitly printed\n return { output: printed ? currentLine : null, deleted: false };\n }\n\n // Without -n, always output (plus extra if printed)\n if (printed) {\n return { output: currentLine + \"\\n\" + currentLine, deleted: false };\n }\n return { output: currentLine, deleted: false };\n}\n\nexport const sed: Command = async (ctx) => {\n const { options, files } = parseArgs(ctx.args);\n\n if (options.commands.length === 0) {\n await ctx.stderr.writeText(\"sed: missing script\\n\");\n return 1;\n }\n\n const processContent = async (content: string): Promise<void> => {\n const lines = content.split(\"\\n\");\n // Handle trailing newline\n if (lines.length > 0 && lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n\n for (const line of lines) {\n const { output } = processLine(line, options.commands, options.suppressOutput);\n if (output !== null) {\n await ctx.stdout.writeText(output + \"\\n\");\n }\n }\n };\n\n if (files.length === 0) {\n // Read from stdin\n const content = await ctx.stdin.text();\n await processContent(content);\n } else if (options.inPlace) {\n // In-place editing: write results back to each file\n for (const file of files) {\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = await ctx.fs.readFile(path);\n const lines = content.toString().split(\"\\n\");\n if (lines.length > 0 && lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n const outputLines: string[] = [];\n for (const line of lines) {\n const { output } = processLine(line, options.commands, options.suppressOutput);\n if (output !== null) {\n outputLines.push(output);\n }\n }\n const result = outputLines.length > 0 ? outputLines.join(\"\\n\") + \"\\n\" : \"\";\n await ctx.fs.writeFile(path, result);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`sed: ${file}: ${message}\\n`);\n return 1;\n }\n }\n } else {\n // Read from files\n for (const file of files) {\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = await ctx.fs.readFile(path);\n await processContent(content.toString());\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`sed: ${file}: ${message}\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,iBAAiB,CAAC,QAAmC;AAAA,EAG5D,MAAM,QAAQ,OAAO,MAAM,6BAA6B;AAAA,EACxD,IAAI,CAAC;AAAA,IAAO,OAAO;AAAA,EAEnB,WAAW,YAAY,aAAa,SAAS;AAAA,EAC7C,MAAM,aAAa,MAAO,SAAS,GAAG;AAAA,EACtC,MAAM,kBAAkB,MAAO,SAAS,GAAG;AAAA,EAE3C,IAAI;AAAA,IACF,MAAM,aAAa,kBAAkB,MAAM;AAAA,IAC3C,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,IAAI,OAAO,YAAa,UAAU;AAAA,MAC3C;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAIX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AAU,MAAM,IAAI,GAAG,SAAS,IAAI;AAAA,QAC1C,MAAM,eAAe,QAAQ,SAAS,CAAC;AAAA,QACvC,OAAO,KAAK;AAAA,QACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,QAC/D,MAAM,IAAI,OAAO,UAAU,QAAQ,SAAS;AAAA,CAAW;AAAA,QACvD,OAAO;AAAA;AAAA,IAEX;AAAA;AAAA,EAGF,OAAO;AAAA;",
8
+ "debugId": "C4AEC38FC548256C64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "shell-dsl",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module"
5
5
  }
@@ -3,9 +3,11 @@ function parseSubstitution(script) {
3
3
  const match = script.match(/^s(.)(.+?)\1(.*?)\1([gi]*)$/);
4
4
  if (!match)
5
5
  return null;
6
- const [, , patternStr, replacement, flags] = match;
6
+ const [, , rawPattern, rawReplacement, flags] = match;
7
7
  const globalFlag = flags.includes("g");
8
8
  const caseInsensitive = flags.includes("i");
9
+ const patternStr = rawPattern.replace(/\\\(/g, "(").replace(/\\\)/g, ")");
10
+ const replacement = rawReplacement.replace(/\\([0-9])/g, "\x00BACKREF$1\x00").replace(/\$/g, "$$$$").replace(/\x00BACKREF([0-9])\x00/g, "$$$1");
9
11
  try {
10
12
  const regexFlags = caseInsensitive ? "i" : "";
11
13
  return {
@@ -64,9 +66,48 @@ function parseCommand(script) {
64
66
  return subCmd;
65
67
  return null;
66
68
  }
69
+ function splitScriptParts(script) {
70
+ const parts = [];
71
+ let i = 0;
72
+ let current = "";
73
+ while (i < script.length) {
74
+ if (script[i] === "s" && i + 1 < script.length) {
75
+ const delim = script[i + 1];
76
+ let j = i + 2;
77
+ let delimCount = 0;
78
+ while (j < script.length && delimCount < 2) {
79
+ if (script[j] === "\\") {
80
+ j += 2;
81
+ continue;
82
+ }
83
+ if (script[j] === delim)
84
+ delimCount++;
85
+ j++;
86
+ }
87
+ while (j < script.length && /[gi]/.test(script[j]))
88
+ j++;
89
+ current += script.slice(i, j);
90
+ i = j;
91
+ } else if (script[i] === ";") {
92
+ const trimmed2 = current.trim();
93
+ if (trimmed2)
94
+ parts.push(trimmed2);
95
+ current = "";
96
+ i++;
97
+ } else {
98
+ current += script[i];
99
+ i++;
100
+ }
101
+ }
102
+ const trimmed = current.trim();
103
+ if (trimmed)
104
+ parts.push(trimmed);
105
+ return parts;
106
+ }
67
107
  function parseArgs(args) {
68
108
  const options = {
69
109
  suppressOutput: false,
110
+ inPlace: false,
70
111
  commands: []
71
112
  };
72
113
  const files = [];
@@ -78,6 +119,11 @@ function parseArgs(args) {
78
119
  i++;
79
120
  continue;
80
121
  }
122
+ if (arg === "-i") {
123
+ options.inPlace = true;
124
+ i++;
125
+ continue;
126
+ }
81
127
  if (arg === "-e" && args[i + 1] !== undefined) {
82
128
  const cmd = parseCommand(args[i + 1]);
83
129
  if (cmd) {
@@ -88,9 +134,12 @@ function parseArgs(args) {
88
134
  }
89
135
  if (!arg.startsWith("-")) {
90
136
  if (options.commands.length === 0) {
91
- const cmd = parseCommand(arg);
92
- if (cmd) {
93
- options.commands.push(cmd);
137
+ const parts = splitScriptParts(arg);
138
+ for (const part of parts) {
139
+ const cmd = parseCommand(part);
140
+ if (cmd) {
141
+ options.commands.push(cmd);
142
+ }
94
143
  }
95
144
  } else {
96
145
  files.push(arg);
@@ -165,6 +214,34 @@ var sed = async (ctx) => {
165
214
  if (files.length === 0) {
166
215
  const content = await ctx.stdin.text();
167
216
  await processContent(content);
217
+ } else if (options.inPlace) {
218
+ for (const file of files) {
219
+ try {
220
+ const path = ctx.fs.resolve(ctx.cwd, file);
221
+ const content = await ctx.fs.readFile(path);
222
+ const lines = content.toString().split(`
223
+ `);
224
+ if (lines.length > 0 && lines[lines.length - 1] === "") {
225
+ lines.pop();
226
+ }
227
+ const outputLines = [];
228
+ for (const line of lines) {
229
+ const { output } = processLine(line, options.commands, options.suppressOutput);
230
+ if (output !== null) {
231
+ outputLines.push(output);
232
+ }
233
+ }
234
+ const result = outputLines.length > 0 ? outputLines.join(`
235
+ `) + `
236
+ ` : "";
237
+ await ctx.fs.writeFile(path, result);
238
+ } catch (err) {
239
+ const message = err instanceof Error ? err.message : String(err);
240
+ await ctx.stderr.writeText(`sed: ${file}: ${message}
241
+ `);
242
+ return 1;
243
+ }
244
+ }
168
245
  } else {
169
246
  for (const file of files) {
170
247
  try {
@@ -185,4 +262,4 @@ export {
185
262
  sed
186
263
  };
187
264
 
188
- //# debugId=87CDDCAD5F22F55864756E2164756E21
265
+ //# debugId=3B08A3537764916864756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/commands/sed/sed.ts"],
4
4
  "sourcesContent": [
5
- "import type { Command } from \"../../types.mjs\";\n\ninterface SedCommand {\n type: \"s\" | \"d\" | \"p\";\n addressPattern?: RegExp;\n pattern?: RegExp;\n replacement?: string;\n globalFlag: boolean;\n printFlag: boolean;\n}\n\ninterface SedOptions {\n suppressOutput: boolean; // -n\n commands: SedCommand[];\n}\n\nfunction parseSubstitution(script: string): SedCommand | null {\n // Match s/pattern/replacement/flags format\n // Support different delimiters (first char after 's')\n const match = script.match(/^s(.)(.+?)\\1(.*?)\\1([gi]*)$/);\n if (!match) return null;\n\n const [, , patternStr, replacement, flags] = match;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n\n try {\n const regexFlags = caseInsensitive ? \"i\" : \"\";\n return {\n type: \"s\",\n pattern: new RegExp(patternStr!, regexFlags),\n replacement: replacement!,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n}\n\nfunction parseCommand(script: string): SedCommand | null {\n const trimmed = script.trim();\n\n // Check for address pattern (e.g., /foo/d or /foo/p)\n const addressMatch = trimmed.match(/^\\/(.+?)\\/([dp])$/);\n if (addressMatch) {\n const [, addressPatternStr, cmd] = addressMatch;\n try {\n return {\n type: cmd as \"d\" | \"p\",\n addressPattern: new RegExp(addressPatternStr!),\n globalFlag: false,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Simple d or p command (applies to all lines)\n if (trimmed === \"d\") {\n return { type: \"d\", globalFlag: false, printFlag: false };\n }\n if (trimmed === \"p\") {\n return { type: \"p\", globalFlag: false, printFlag: false };\n }\n\n // Address pattern with substitution: /pattern/s/old/new/flags\n const addressSubMatch = trimmed.match(/^\\/(.+?)\\/s(.)(.+?)\\2(.*?)\\2([gi]*)$/);\n if (addressSubMatch) {\n const [, addressPatternStr, , patternStr, replacement, flags] = addressSubMatch;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n try {\n return {\n type: \"s\",\n addressPattern: new RegExp(addressPatternStr!),\n pattern: new RegExp(patternStr!, caseInsensitive ? \"i\" : \"\"),\n replacement: replacement!,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Substitution command\n const subCmd = parseSubstitution(trimmed);\n if (subCmd) return subCmd;\n\n return null;\n}\n\nfunction parseArgs(args: string[]): { options: SedOptions; files: string[] } {\n const options: SedOptions = {\n suppressOutput: false,\n commands: [],\n };\n const files: string[] = [];\n\n let i = 0;\n while (i < args.length) {\n const arg = args[i]!;\n\n if (arg === \"-n\") {\n options.suppressOutput = true;\n i++;\n continue;\n }\n\n if (arg === \"-e\" && args[i + 1] !== undefined) {\n const cmd = parseCommand(args[i + 1]!);\n if (cmd) {\n options.commands.push(cmd);\n }\n i += 2;\n continue;\n }\n\n // Non-flag argument: either a script or a file\n if (!arg.startsWith(\"-\")) {\n if (options.commands.length === 0) {\n // First non-flag is the script\n const cmd = parseCommand(arg);\n if (cmd) {\n options.commands.push(cmd);\n }\n } else {\n // Subsequent non-flags are files\n files.push(arg);\n }\n }\n i++;\n }\n\n return { options, files };\n}\n\nfunction applySubstitution(line: string, cmd: SedCommand): string {\n if (!cmd.pattern) return line;\n\n if (cmd.globalFlag) {\n return line.replace(new RegExp(cmd.pattern.source, cmd.pattern.flags + \"g\"), cmd.replacement!);\n } else {\n return line.replace(cmd.pattern, cmd.replacement!);\n }\n}\n\nfunction processLine(\n line: string,\n commands: SedCommand[],\n suppressOutput: boolean\n): { output: string | null; deleted: boolean } {\n let currentLine = line;\n let deleted = false;\n let printed = false;\n\n for (const cmd of commands) {\n // Check address pattern first\n if (cmd.addressPattern && !cmd.addressPattern.test(currentLine)) {\n continue; // Skip this command if address doesn't match\n }\n\n switch (cmd.type) {\n case \"s\":\n currentLine = applySubstitution(currentLine, cmd);\n break;\n case \"d\":\n deleted = true;\n return { output: null, deleted: true };\n case \"p\":\n printed = true;\n break;\n }\n }\n\n if (deleted) {\n return { output: null, deleted: true };\n }\n\n if (suppressOutput) {\n // With -n, only output if explicitly printed\n return { output: printed ? currentLine : null, deleted: false };\n }\n\n // Without -n, always output (plus extra if printed)\n if (printed) {\n return { output: currentLine + \"\\n\" + currentLine, deleted: false };\n }\n return { output: currentLine, deleted: false };\n}\n\nexport const sed: Command = async (ctx) => {\n const { options, files } = parseArgs(ctx.args);\n\n if (options.commands.length === 0) {\n await ctx.stderr.writeText(\"sed: missing script\\n\");\n return 1;\n }\n\n const processContent = async (content: string): Promise<void> => {\n const lines = content.split(\"\\n\");\n // Handle trailing newline\n if (lines.length > 0 && lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n\n for (const line of lines) {\n const { output } = processLine(line, options.commands, options.suppressOutput);\n if (output !== null) {\n await ctx.stdout.writeText(output + \"\\n\");\n }\n }\n };\n\n if (files.length === 0) {\n // Read from stdin\n const content = await ctx.stdin.text();\n await processContent(content);\n } else {\n // Read from files\n for (const file of files) {\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = await ctx.fs.readFile(path);\n await processContent(content.toString());\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`sed: ${file}: ${message}\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
5
+ "import type { Command } from \"../../types.mjs\";\n\ninterface SedCommand {\n type: \"s\" | \"d\" | \"p\";\n addressPattern?: RegExp;\n pattern?: RegExp;\n replacement?: string;\n globalFlag: boolean;\n printFlag: boolean;\n}\n\ninterface SedOptions {\n suppressOutput: boolean; // -n\n inPlace: boolean; // -i\n commands: SedCommand[];\n}\n\nfunction parseSubstitution(script: string): SedCommand | null {\n // Match s/pattern/replacement/flags format\n // Support different delimiters (first char after 's')\n const match = script.match(/^s(.)(.+?)\\1(.*?)\\1([gi]*)$/);\n if (!match) return null;\n\n const [, , rawPattern, rawReplacement, flags] = match;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n\n // Convert sed-style \\( \\) to JS ( ) for capture groups\n const patternStr = rawPattern!.replace(/\\\\\\(/g, \"(\").replace(/\\\\\\)/g, \")\");\n // Convert sed replacement to JS String.replace format:\n // 1. Mark backreferences \\1..\\9 with placeholders\n // 2. Escape $ so String.replace doesn't treat $$ as special\n // 3. Restore backreference placeholders as $1..$9\n const replacement = rawReplacement!\n .replace(/\\\\([0-9])/g, \"\\x00BACKREF$1\\x00\")\n .replace(/\\$/g, \"$$$$\")\n .replace(/\\x00BACKREF([0-9])\\x00/g, \"$$$1\");\n\n try {\n const regexFlags = caseInsensitive ? \"i\" : \"\";\n return {\n type: \"s\",\n pattern: new RegExp(patternStr, regexFlags),\n replacement,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n}\n\nfunction parseCommand(script: string): SedCommand | null {\n const trimmed = script.trim();\n\n // Check for address pattern (e.g., /foo/d or /foo/p)\n const addressMatch = trimmed.match(/^\\/(.+?)\\/([dp])$/);\n if (addressMatch) {\n const [, addressPatternStr, cmd] = addressMatch;\n try {\n return {\n type: cmd as \"d\" | \"p\",\n addressPattern: new RegExp(addressPatternStr!),\n globalFlag: false,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Simple d or p command (applies to all lines)\n if (trimmed === \"d\") {\n return { type: \"d\", globalFlag: false, printFlag: false };\n }\n if (trimmed === \"p\") {\n return { type: \"p\", globalFlag: false, printFlag: false };\n }\n\n // Address pattern with substitution: /pattern/s/old/new/flags\n const addressSubMatch = trimmed.match(/^\\/(.+?)\\/s(.)(.+?)\\2(.*?)\\2([gi]*)$/);\n if (addressSubMatch) {\n const [, addressPatternStr, , patternStr, replacement, flags] = addressSubMatch;\n const globalFlag = flags!.includes(\"g\");\n const caseInsensitive = flags!.includes(\"i\");\n try {\n return {\n type: \"s\",\n addressPattern: new RegExp(addressPatternStr!),\n pattern: new RegExp(patternStr!, caseInsensitive ? \"i\" : \"\"),\n replacement: replacement!,\n globalFlag,\n printFlag: false,\n };\n } catch {\n return null;\n }\n }\n\n // Substitution command\n const subCmd = parseSubstitution(trimmed);\n if (subCmd) return subCmd;\n\n return null;\n}\n\nfunction splitScriptParts(script: string): string[] {\n // Split on ';' that are outside of s/// delimiters\n const parts: string[] = [];\n let i = 0;\n let current = \"\";\n while (i < script.length) {\n if (script[i] === \"s\" && i + 1 < script.length) {\n // Detect substitution command — consume s/pattern/replacement/flags\n const delim = script[i + 1]!;\n let j = i + 2;\n let delimCount = 0;\n while (j < script.length && delimCount < 2) {\n if (script[j] === \"\\\\\") {\n j += 2;\n continue;\n }\n if (script[j] === delim) delimCount++;\n j++;\n }\n // Consume trailing flags\n while (j < script.length && /[gi]/.test(script[j]!)) j++;\n current += script.slice(i, j);\n i = j;\n } else if (script[i] === \";\") {\n const trimmed = current.trim();\n if (trimmed) parts.push(trimmed);\n current = \"\";\n i++;\n } else {\n current += script[i];\n i++;\n }\n }\n const trimmed = current.trim();\n if (trimmed) parts.push(trimmed);\n return parts;\n}\n\nfunction parseArgs(args: string[]): { options: SedOptions; files: string[] } {\n const options: SedOptions = {\n suppressOutput: false,\n inPlace: false,\n commands: [],\n };\n const files: string[] = [];\n\n let i = 0;\n while (i < args.length) {\n const arg = args[i]!;\n\n if (arg === \"-n\") {\n options.suppressOutput = true;\n i++;\n continue;\n }\n\n if (arg === \"-i\") {\n options.inPlace = true;\n i++;\n continue;\n }\n\n if (arg === \"-e\" && args[i + 1] !== undefined) {\n const cmd = parseCommand(args[i + 1]!);\n if (cmd) {\n options.commands.push(cmd);\n }\n i += 2;\n continue;\n }\n\n // Non-flag argument: either a script or a file\n if (!arg.startsWith(\"-\")) {\n if (options.commands.length === 0) {\n // First non-flag is the script — may contain ;-separated commands\n const parts = splitScriptParts(arg);\n for (const part of parts) {\n const cmd = parseCommand(part);\n if (cmd) {\n options.commands.push(cmd);\n }\n }\n } else {\n // Subsequent non-flags are files\n files.push(arg);\n }\n }\n i++;\n }\n\n return { options, files };\n}\n\nfunction applySubstitution(line: string, cmd: SedCommand): string {\n if (!cmd.pattern) return line;\n\n if (cmd.globalFlag) {\n return line.replace(new RegExp(cmd.pattern.source, cmd.pattern.flags + \"g\"), cmd.replacement!);\n } else {\n return line.replace(cmd.pattern, cmd.replacement!);\n }\n}\n\nfunction processLine(\n line: string,\n commands: SedCommand[],\n suppressOutput: boolean\n): { output: string | null; deleted: boolean } {\n let currentLine = line;\n let deleted = false;\n let printed = false;\n\n for (const cmd of commands) {\n // Check address pattern first\n if (cmd.addressPattern && !cmd.addressPattern.test(currentLine)) {\n continue; // Skip this command if address doesn't match\n }\n\n switch (cmd.type) {\n case \"s\":\n currentLine = applySubstitution(currentLine, cmd);\n break;\n case \"d\":\n deleted = true;\n return { output: null, deleted: true };\n case \"p\":\n printed = true;\n break;\n }\n }\n\n if (deleted) {\n return { output: null, deleted: true };\n }\n\n if (suppressOutput) {\n // With -n, only output if explicitly printed\n return { output: printed ? currentLine : null, deleted: false };\n }\n\n // Without -n, always output (plus extra if printed)\n if (printed) {\n return { output: currentLine + \"\\n\" + currentLine, deleted: false };\n }\n return { output: currentLine, deleted: false };\n}\n\nexport const sed: Command = async (ctx) => {\n const { options, files } = parseArgs(ctx.args);\n\n if (options.commands.length === 0) {\n await ctx.stderr.writeText(\"sed: missing script\\n\");\n return 1;\n }\n\n const processContent = async (content: string): Promise<void> => {\n const lines = content.split(\"\\n\");\n // Handle trailing newline\n if (lines.length > 0 && lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n\n for (const line of lines) {\n const { output } = processLine(line, options.commands, options.suppressOutput);\n if (output !== null) {\n await ctx.stdout.writeText(output + \"\\n\");\n }\n }\n };\n\n if (files.length === 0) {\n // Read from stdin\n const content = await ctx.stdin.text();\n await processContent(content);\n } else if (options.inPlace) {\n // In-place editing: write results back to each file\n for (const file of files) {\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = await ctx.fs.readFile(path);\n const lines = content.toString().split(\"\\n\");\n if (lines.length > 0 && lines[lines.length - 1] === \"\") {\n lines.pop();\n }\n const outputLines: string[] = [];\n for (const line of lines) {\n const { output } = processLine(line, options.commands, options.suppressOutput);\n if (output !== null) {\n outputLines.push(output);\n }\n }\n const result = outputLines.length > 0 ? outputLines.join(\"\\n\") + \"\\n\" : \"\";\n await ctx.fs.writeFile(path, result);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`sed: ${file}: ${message}\\n`);\n return 1;\n }\n }\n } else {\n // Read from files\n for (const file of files) {\n try {\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = await ctx.fs.readFile(path);\n await processContent(content.toString());\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`sed: ${file}: ${message}\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
6
6
  ],
7
- "mappings": ";AAgBA,SAAS,iBAAiB,CAAC,QAAmC;AAAA,EAG5D,MAAM,QAAQ,OAAO,MAAM,6BAA6B;AAAA,EACxD,IAAI,CAAC;AAAA,IAAO,OAAO;AAAA,EAEnB,WAAW,YAAY,aAAa,SAAS;AAAA,EAC7C,MAAM,aAAa,MAAO,SAAS,GAAG;AAAA,EACtC,MAAM,kBAAkB,MAAO,SAAS,GAAG;AAAA,EAE3C,IAAI;AAAA,IACF,MAAM,aAAa,kBAAkB,MAAM;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EAAO;AAAA,IAEL,WAAW,QAAQ,OAAO;AAAA,MACxB,IAAI;AAAA,QACF,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI,KAAK,IAAI;AAAA,QACzC,MAAM,UAAU,MAAM,IAAI,GAAG,SAAS,IAAI;AAAA,QAC1C,MAAM,eAAe,QAAQ,SAAS,CAAC;AAAA,QACvC,OAAO,KAAK;AAAA,QACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,QAC/D,MAAM,IAAI,OAAO,UAAU,QAAQ,SAAS;AAAA,CAAW;AAAA,QACvD,OAAO;AAAA;AAAA,IAEX;AAAA;AAAA,EAGF,OAAO;AAAA;",
8
+ "debugId": "3B08A3537764916864756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shell-dsl",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A sandboxed shell-style DSL for running scriptable command pipelines in-process without host OS access",
5
5
  "author": "ricsam <oss@ricsam.dev>",
6
6
  "license": "MIT",