typescript-virtual-container 1.2.5 → 1.2.6

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.
Files changed (245) hide show
  1. package/README.md +387 -193
  2. package/benchmark-results.txt +21 -21
  3. package/dist/SSHMimic/exec.js +2 -2
  4. package/dist/SSHMimic/executor.d.ts +6 -7
  5. package/dist/SSHMimic/executor.d.ts.map +1 -1
  6. package/dist/SSHMimic/executor.js +77 -60
  7. package/dist/SSHMimic/index.d.ts.map +1 -1
  8. package/dist/SSHMimic/index.js +6 -20
  9. package/dist/SSHMimic/sftp.d.ts.map +1 -1
  10. package/dist/SSHMimic/sftp.js +14 -0
  11. package/dist/VirtualFileSystem/index.d.ts.map +1 -1
  12. package/dist/VirtualFileSystem/index.js +13 -36
  13. package/dist/VirtualShell/shell.d.ts.map +1 -1
  14. package/dist/VirtualShell/shell.js +19 -2
  15. package/dist/VirtualShell/shellParser.d.ts +20 -2
  16. package/dist/VirtualShell/shellParser.d.ts.map +1 -1
  17. package/dist/VirtualShell/shellParser.js +229 -120
  18. package/dist/VirtualUserManager/index.d.ts.map +1 -1
  19. package/dist/commands/adduser.d.ts.map +1 -1
  20. package/dist/commands/adduser.js +2 -0
  21. package/dist/commands/awk.d.ts +3 -0
  22. package/dist/commands/awk.d.ts.map +1 -0
  23. package/dist/commands/awk.js +29 -0
  24. package/dist/commands/base64.d.ts +3 -0
  25. package/dist/commands/base64.d.ts.map +1 -0
  26. package/dist/commands/base64.js +20 -0
  27. package/dist/commands/cat.d.ts.map +1 -1
  28. package/dist/commands/cat.js +2 -0
  29. package/dist/commands/cd.d.ts.map +1 -1
  30. package/dist/commands/cd.js +2 -0
  31. package/dist/commands/chmod.d.ts.map +1 -1
  32. package/dist/commands/chmod.js +2 -0
  33. package/dist/commands/clear.d.ts.map +1 -1
  34. package/dist/commands/clear.js +4 -1
  35. package/dist/commands/cp.d.ts.map +1 -1
  36. package/dist/commands/cp.js +2 -0
  37. package/dist/commands/curl.d.ts.map +1 -1
  38. package/dist/commands/curl.js +2 -0
  39. package/dist/commands/cut.d.ts +3 -0
  40. package/dist/commands/cut.d.ts.map +1 -0
  41. package/dist/commands/cut.js +27 -0
  42. package/dist/commands/date.d.ts +3 -0
  43. package/dist/commands/date.d.ts.map +1 -0
  44. package/dist/commands/date.js +22 -0
  45. package/dist/commands/deluser.d.ts.map +1 -1
  46. package/dist/commands/deluser.js +2 -0
  47. package/dist/commands/df.d.ts +3 -0
  48. package/dist/commands/df.d.ts.map +1 -0
  49. package/dist/commands/df.js +16 -0
  50. package/dist/commands/diff.d.ts +3 -0
  51. package/dist/commands/diff.d.ts.map +1 -0
  52. package/dist/commands/diff.js +40 -0
  53. package/dist/commands/du.d.ts +3 -0
  54. package/dist/commands/du.d.ts.map +1 -0
  55. package/dist/commands/du.js +39 -0
  56. package/dist/commands/echo.d.ts.map +1 -1
  57. package/dist/commands/echo.js +2 -0
  58. package/dist/commands/env.d.ts.map +1 -1
  59. package/dist/commands/env.js +6 -14
  60. package/dist/commands/export.d.ts.map +1 -1
  61. package/dist/commands/export.js +11 -21
  62. package/dist/commands/find.d.ts.map +1 -1
  63. package/dist/commands/find.js +2 -0
  64. package/dist/commands/grep.d.ts.map +1 -1
  65. package/dist/commands/grep.js +4 -7
  66. package/dist/commands/groups.d.ts +3 -0
  67. package/dist/commands/groups.d.ts.map +1 -0
  68. package/dist/commands/groups.js +12 -0
  69. package/dist/commands/gzip.d.ts +4 -0
  70. package/dist/commands/gzip.d.ts.map +1 -0
  71. package/dist/commands/gzip.js +40 -0
  72. package/dist/commands/head.d.ts.map +1 -1
  73. package/dist/commands/head.js +2 -0
  74. package/dist/commands/help.d.ts +1 -1
  75. package/dist/commands/help.d.ts.map +1 -1
  76. package/dist/commands/help.js +75 -3
  77. package/dist/commands/hostname.d.ts.map +1 -1
  78. package/dist/commands/hostname.js +2 -0
  79. package/dist/commands/htop.d.ts.map +1 -1
  80. package/dist/commands/htop.js +2 -0
  81. package/dist/commands/id.d.ts +3 -0
  82. package/dist/commands/id.d.ts.map +1 -0
  83. package/dist/commands/id.js +14 -0
  84. package/dist/commands/index.d.ts +5 -2
  85. package/dist/commands/index.d.ts.map +1 -1
  86. package/dist/commands/index.js +89 -62
  87. package/dist/commands/kill.d.ts +3 -0
  88. package/dist/commands/kill.d.ts.map +1 -0
  89. package/dist/commands/kill.js +13 -0
  90. package/dist/commands/ln.d.ts.map +1 -1
  91. package/dist/commands/ln.js +2 -0
  92. package/dist/commands/ls.d.ts.map +1 -1
  93. package/dist/commands/ls.js +2 -0
  94. package/dist/commands/mkdir.d.ts.map +1 -1
  95. package/dist/commands/mkdir.js +2 -0
  96. package/dist/commands/mv.d.ts.map +1 -1
  97. package/dist/commands/mv.js +2 -0
  98. package/dist/commands/nano.d.ts.map +1 -1
  99. package/dist/commands/nano.js +2 -0
  100. package/dist/commands/neofetch.d.ts.map +1 -1
  101. package/dist/commands/neofetch.js +2 -0
  102. package/dist/commands/passwd.d.ts.map +1 -1
  103. package/dist/commands/passwd.js +2 -0
  104. package/dist/commands/ping.d.ts +3 -0
  105. package/dist/commands/ping.d.ts.map +1 -0
  106. package/dist/commands/ping.js +18 -0
  107. package/dist/commands/ps.d.ts +3 -0
  108. package/dist/commands/ps.d.ts.map +1 -0
  109. package/dist/commands/ps.js +17 -0
  110. package/dist/commands/pwd.d.ts.map +1 -1
  111. package/dist/commands/pwd.js +2 -0
  112. package/dist/commands/rm.d.ts.map +1 -1
  113. package/dist/commands/rm.js +2 -0
  114. package/dist/commands/sed.d.ts +3 -0
  115. package/dist/commands/sed.d.ts.map +1 -0
  116. package/dist/commands/sed.js +47 -0
  117. package/dist/commands/set.d.ts +3 -0
  118. package/dist/commands/set.d.ts.map +1 -1
  119. package/dist/commands/set.js +19 -46
  120. package/dist/commands/sh.d.ts +0 -1
  121. package/dist/commands/sh.d.ts.map +1 -1
  122. package/dist/commands/sh.js +228 -35
  123. package/dist/commands/sleep.d.ts +3 -0
  124. package/dist/commands/sleep.d.ts.map +1 -0
  125. package/dist/commands/sleep.js +13 -0
  126. package/dist/commands/sort.d.ts +3 -0
  127. package/dist/commands/sort.d.ts.map +1 -0
  128. package/dist/commands/sort.js +37 -0
  129. package/dist/commands/su.d.ts.map +1 -1
  130. package/dist/commands/su.js +2 -0
  131. package/dist/commands/sudo.d.ts.map +1 -1
  132. package/dist/commands/sudo.js +2 -0
  133. package/dist/commands/tail.d.ts.map +1 -1
  134. package/dist/commands/tail.js +2 -0
  135. package/dist/commands/tar.d.ts +3 -0
  136. package/dist/commands/tar.d.ts.map +1 -0
  137. package/dist/commands/tar.js +64 -0
  138. package/dist/commands/tee.d.ts +3 -0
  139. package/dist/commands/tee.d.ts.map +1 -0
  140. package/dist/commands/tee.js +29 -0
  141. package/dist/commands/touch.d.ts.map +1 -1
  142. package/dist/commands/touch.js +2 -0
  143. package/dist/commands/tr.d.ts +3 -0
  144. package/dist/commands/tr.d.ts.map +1 -0
  145. package/dist/commands/tr.js +24 -0
  146. package/dist/commands/tree.d.ts.map +1 -1
  147. package/dist/commands/tree.js +2 -0
  148. package/dist/commands/uname.d.ts +3 -0
  149. package/dist/commands/uname.d.ts.map +1 -0
  150. package/dist/commands/uname.js +21 -0
  151. package/dist/commands/uniq.d.ts +3 -0
  152. package/dist/commands/uniq.d.ts.map +1 -0
  153. package/dist/commands/uniq.js +33 -0
  154. package/dist/commands/unset.d.ts.map +1 -1
  155. package/dist/commands/unset.js +6 -10
  156. package/dist/commands/wc.d.ts.map +1 -1
  157. package/dist/commands/wc.js +2 -0
  158. package/dist/commands/wget.d.ts.map +1 -1
  159. package/dist/commands/wget.js +2 -0
  160. package/dist/commands/who.d.ts.map +1 -1
  161. package/dist/commands/who.js +2 -0
  162. package/dist/commands/whoami.d.ts.map +1 -1
  163. package/dist/commands/whoami.js +2 -0
  164. package/dist/commands/xargs.d.ts +3 -0
  165. package/dist/commands/xargs.d.ts.map +1 -0
  166. package/dist/commands/xargs.js +16 -0
  167. package/dist/types/commands.d.ts +13 -0
  168. package/dist/types/commands.d.ts.map +1 -1
  169. package/dist/types/pipeline.d.ts +20 -0
  170. package/dist/types/pipeline.d.ts.map +1 -1
  171. package/package.json +1 -1
  172. package/src/SSHMimic/exec.ts +2 -2
  173. package/src/SSHMimic/executor.ts +95 -98
  174. package/src/SSHMimic/index.ts +15 -49
  175. package/src/SSHMimic/sftp.ts +15 -0
  176. package/src/VirtualFileSystem/index.ts +27 -75
  177. package/src/VirtualShell/shell.ts +19 -2
  178. package/src/VirtualShell/shellParser.ts +202 -168
  179. package/src/VirtualUserManager/index.ts +2 -7
  180. package/src/commands/adduser.ts +2 -0
  181. package/src/commands/awk.ts +30 -0
  182. package/src/commands/base64.ts +18 -0
  183. package/src/commands/cat.ts +2 -0
  184. package/src/commands/cd.ts +2 -0
  185. package/src/commands/chmod.ts +2 -0
  186. package/src/commands/clear.ts +4 -1
  187. package/src/commands/cp.ts +2 -0
  188. package/src/commands/curl.ts +2 -0
  189. package/src/commands/cut.ts +29 -0
  190. package/src/commands/date.ts +24 -0
  191. package/src/commands/deluser.ts +2 -0
  192. package/src/commands/df.ts +18 -0
  193. package/src/commands/diff.ts +29 -0
  194. package/src/commands/du.ts +39 -0
  195. package/src/commands/echo.ts +2 -0
  196. package/src/commands/env.ts +6 -16
  197. package/src/commands/export.ts +11 -24
  198. package/src/commands/find.ts +2 -0
  199. package/src/commands/grep.ts +4 -7
  200. package/src/commands/groups.ts +14 -0
  201. package/src/commands/gzip.ts +31 -0
  202. package/src/commands/head.ts +2 -0
  203. package/src/commands/help.ts +81 -3
  204. package/src/commands/hostname.ts +2 -0
  205. package/src/commands/htop.ts +2 -0
  206. package/src/commands/id.ts +16 -0
  207. package/src/commands/index.ts +98 -99
  208. package/src/commands/kill.ts +14 -0
  209. package/src/commands/ln.ts +2 -0
  210. package/src/commands/ls.ts +2 -0
  211. package/src/commands/mkdir.ts +2 -0
  212. package/src/commands/mv.ts +2 -0
  213. package/src/commands/nano.ts +2 -0
  214. package/src/commands/neofetch.ts +2 -0
  215. package/src/commands/passwd.ts +2 -0
  216. package/src/commands/ping.ts +20 -0
  217. package/src/commands/ps.ts +19 -0
  218. package/src/commands/pwd.ts +2 -0
  219. package/src/commands/rm.ts +2 -0
  220. package/src/commands/sed.ts +45 -0
  221. package/src/commands/set.ts +19 -50
  222. package/src/commands/sh.ts +192 -43
  223. package/src/commands/sleep.ts +14 -0
  224. package/src/commands/sort.ts +37 -0
  225. package/src/commands/su.ts +2 -0
  226. package/src/commands/sudo.ts +2 -0
  227. package/src/commands/tail.ts +2 -0
  228. package/src/commands/tar.ts +58 -0
  229. package/src/commands/tee.ts +25 -0
  230. package/src/commands/touch.ts +2 -0
  231. package/src/commands/tr.ts +24 -0
  232. package/src/commands/tree.ts +2 -0
  233. package/src/commands/uname.ts +20 -0
  234. package/src/commands/uniq.ts +28 -0
  235. package/src/commands/unset.ts +5 -12
  236. package/src/commands/wc.ts +2 -0
  237. package/src/commands/wget.ts +2 -0
  238. package/src/commands/who.ts +2 -0
  239. package/src/commands/whoami.ts +2 -0
  240. package/src/commands/xargs.ts +17 -0
  241. package/src/types/commands.ts +14 -0
  242. package/src/types/pipeline.ts +23 -0
  243. package/standalone.js +92 -64
  244. package/standalone.js.map +4 -4
  245. package/tests/users.test.ts +5 -34
@@ -210,11 +210,7 @@ class VirtualFileSystem extends EventEmitter {
210
210
  public mkdir(targetPath: string, mode: number = 0o755): void {
211
211
  const normalized = normalizePath(targetPath);
212
212
  const existing = (() => {
213
- try {
214
- return getNode(this.root, normalized);
215
- } catch {
216
- return null;
217
- }
213
+ try { return getNode(this.root, normalized); } catch { return null; }
218
214
  })();
219
215
  if (existing && existing.type !== "directory") {
220
216
  throw new Error(
@@ -305,9 +301,7 @@ class VirtualFileSystem extends EventEmitter {
305
301
  try {
306
302
  getNode(this.root, normalizePath(targetPath));
307
303
  return true;
308
- } catch {
309
- return false;
310
- }
304
+ } catch { return false; }
311
305
  }
312
306
 
313
307
  /** Updates mode bits on a node. */
@@ -323,24 +317,15 @@ class VirtualFileSystem extends EventEmitter {
323
317
  if (node.type === "file") {
324
318
  const f = node as InternalFileNode;
325
319
  return {
326
- type: "file",
327
- name,
328
- path: normalized,
329
- mode: f.mode,
330
- createdAt: f.createdAt,
331
- updatedAt: f.updatedAt,
332
- compressed: f.compressed,
333
- size: f.content.length,
320
+ type: "file", name, path: normalized, mode: f.mode,
321
+ createdAt: f.createdAt, updatedAt: f.updatedAt,
322
+ compressed: f.compressed, size: f.content.length,
334
323
  };
335
324
  }
336
325
  const d = node as InternalDirectoryNode;
337
326
  return {
338
- type: "directory",
339
- name,
340
- path: normalized,
341
- mode: d.mode,
342
- createdAt: d.createdAt,
343
- updatedAt: d.updatedAt,
327
+ type: "directory", name, path: normalized, mode: d.mode,
328
+ createdAt: d.createdAt, updatedAt: d.updatedAt,
344
329
  childrenCount: d.children.size,
345
330
  };
346
331
  }
@@ -360,7 +345,9 @@ class VirtualFileSystem extends EventEmitter {
360
345
  const normalized = normalizePath(dirPath);
361
346
  const node = getNode(this.root, normalized);
362
347
  if (node.type !== "directory") {
363
- throw new Error(`Cannot render tree for '${dirPath}': not a directory.`);
348
+ throw new Error(
349
+ `Cannot render tree for '${dirPath}': not a directory.`,
350
+ );
364
351
  }
365
352
  const label = dirPath === "/" ? "/" : path.posix.basename(normalized);
366
353
  return this.renderTreeLines(node as InternalDirectoryNode, label);
@@ -378,8 +365,7 @@ class VirtualFileSystem extends EventEmitter {
378
365
  lines.push(`${connector}${name}`);
379
366
  if (child.type === "directory") {
380
367
  const sub = this.renderTreeLines(child as InternalDirectoryNode, "")
381
- .split("\n")
382
- .slice(1)
368
+ .split("\n").slice(1)
383
369
  .map((l) => `${nextPrefix}${l}`);
384
370
  lines.push(...sub);
385
371
  }
@@ -404,8 +390,7 @@ class VirtualFileSystem extends EventEmitter {
404
390
  /** Compresses a file's content with gzip in place. */
405
391
  public compressFile(targetPath: string): void {
406
392
  const node = getNode(this.root, normalizePath(targetPath));
407
- if (node.type !== "file")
408
- throw new Error(`Cannot compress '${targetPath}': not a file.`);
393
+ if (node.type !== "file") throw new Error(`Cannot compress '${targetPath}': not a file.`);
409
394
  const f = node as InternalFileNode;
410
395
  if (!f.compressed) {
411
396
  f.content = gzipSync(f.content);
@@ -417,8 +402,7 @@ class VirtualFileSystem extends EventEmitter {
417
402
  /** Decompresses a gzip-compressed file in place. */
418
403
  public decompressFile(targetPath: string): void {
419
404
  const node = getNode(this.root, normalizePath(targetPath));
420
- if (node.type !== "file")
421
- throw new Error(`Cannot decompress '${targetPath}': not a file.`);
405
+ if (node.type !== "file") throw new Error(`Cannot decompress '${targetPath}': not a file.`);
422
406
  const f = node as InternalFileNode;
423
407
  if (f.compressed) {
424
408
  f.content = gunzipSync(f.content);
@@ -437,25 +421,18 @@ class VirtualFileSystem extends EventEmitter {
437
421
  ? normalizePath(targetPath)
438
422
  : targetPath;
439
423
  const { parent, name } = getParentDirectory(
440
- this.root,
441
- normalizedLink,
442
- true,
424
+ this.root, normalizedLink, true,
443
425
  (p) => this.mkdirRecursive(p, 0o755),
444
426
  );
445
427
  const symNode: InternalFileNode = {
446
- type: "file",
447
- name,
428
+ type: "file", name,
448
429
  content: Buffer.from(normalizedTarget, "utf8"),
449
430
  mode: 0o120777,
450
431
  compressed: false,
451
- createdAt: new Date(),
452
- updatedAt: new Date(),
432
+ createdAt: new Date(), updatedAt: new Date(),
453
433
  };
454
434
  parent.children.set(name, symNode);
455
- this.emit("symlink:create", {
456
- link: normalizedLink,
457
- target: normalizedTarget,
458
- });
435
+ this.emit("symlink:create", { link: normalizedLink, target: normalizedTarget });
459
436
  }
460
437
 
461
438
  /** Returns true when the path is a symbolic link node. */
@@ -463,9 +440,7 @@ class VirtualFileSystem extends EventEmitter {
463
440
  try {
464
441
  const node = getNode(this.root, normalizePath(targetPath));
465
442
  return node.type === "file" && node.mode === 0o120777;
466
- } catch {
467
- return false;
468
- }
443
+ } catch { return false; }
469
444
  }
470
445
 
471
446
  /**
@@ -481,14 +456,10 @@ class VirtualFileSystem extends EventEmitter {
481
456
  const target = (node as InternalFileNode).content.toString("utf8");
482
457
  current = target.startsWith("/")
483
458
  ? target
484
- : normalizePath(
485
- path.posix.join(path.posix.dirname(current), target),
486
- );
459
+ : normalizePath(path.posix.join(path.posix.dirname(current), target));
487
460
  continue;
488
461
  }
489
- } catch {
490
- break;
491
- }
462
+ } catch { break; }
492
463
  return current;
493
464
  }
494
465
  throw new Error(`Too many levels of symbolic links: ${linkPath}`);
@@ -507,12 +478,7 @@ class VirtualFileSystem extends EventEmitter {
507
478
  );
508
479
  }
509
480
  }
510
- const { parent, name } = getParentDirectory(
511
- this.root,
512
- normalized,
513
- false,
514
- () => {},
515
- );
481
+ const { parent, name } = getParentDirectory(this.root, normalized, false, () => {});
516
482
  parent.children.delete(name);
517
483
  this.emit("node:remove", { path: normalized });
518
484
  }
@@ -530,16 +496,10 @@ class VirtualFileSystem extends EventEmitter {
530
496
  }
531
497
  this.mkdirRecursive(path.posix.dirname(toNormalized), 0o755);
532
498
  const { parent: destParent, name: destName } = getParentDirectory(
533
- this.root,
534
- toNormalized,
535
- false,
536
- () => {},
499
+ this.root, toNormalized, false, () => {},
537
500
  );
538
501
  const { parent: srcParent, name: srcName } = getParentDirectory(
539
- this.root,
540
- fromNormalized,
541
- false,
542
- () => {},
502
+ this.root, fromNormalized, false, () => {},
543
503
  );
544
504
  srcParent.children.delete(srcName);
545
505
  node.name = destName;
@@ -568,9 +528,7 @@ class VirtualFileSystem extends EventEmitter {
568
528
  );
569
529
  }
570
530
  return {
571
- type: "directory",
572
- name: dir.name,
573
- mode: dir.mode,
531
+ type: "directory", name: dir.name, mode: dir.mode,
574
532
  createdAt: dir.createdAt.toISOString(),
575
533
  updatedAt: dir.updatedAt.toISOString(),
576
534
  children,
@@ -579,9 +537,7 @@ class VirtualFileSystem extends EventEmitter {
579
537
 
580
538
  private serializeFile(file: InternalFileNode): VfsSnapshotFileNode {
581
539
  return {
582
- type: "file",
583
- name: file.name,
584
- mode: file.mode,
540
+ type: "file", name: file.name, mode: file.mode,
585
541
  createdAt: file.createdAt.toISOString(),
586
542
  updatedAt: file.updatedAt.toISOString(),
587
543
  compressed: file.compressed,
@@ -622,9 +578,7 @@ class VirtualFileSystem extends EventEmitter {
622
578
  name: string,
623
579
  ): InternalDirectoryNode {
624
580
  const dir: InternalDirectoryNode = {
625
- type: "directory",
626
- name,
627
- mode: snap.mode,
581
+ type: "directory", name, mode: snap.mode,
628
582
  createdAt: new Date(snap.createdAt),
629
583
  updatedAt: new Date(snap.updatedAt),
630
584
  children: new Map(),
@@ -633,9 +587,7 @@ class VirtualFileSystem extends EventEmitter {
633
587
  if (child.type === "file") {
634
588
  const f = child as VfsSnapshotFileNode;
635
589
  dir.children.set(f.name, {
636
- type: "file",
637
- name: f.name,
638
- mode: f.mode,
590
+ type: "file", name: f.name, mode: f.mode,
639
591
  createdAt: new Date(f.createdAt),
640
592
  updatedAt: new Date(f.updatedAt),
641
593
  compressed: f.compressed,
@@ -2,7 +2,8 @@ import type { ChildProcessWithoutNullStreams } from "node:child_process";
2
2
  import { readFile, unlink, writeFile } from "node:fs/promises";
3
3
  import * as path from "node:path";
4
4
  import type { ShellProperties, VirtualShell } from ".";
5
- import { getCommandNames, runCommand } from "../commands";
5
+ import { getCommandNames, makeDefaultEnv, runCommand } from "../commands";
6
+ import type { ShellEnv } from "../types/commands";
6
7
  import {
7
8
  spawnHtopProcess,
8
9
  spawnNanoEditorProcess,
@@ -50,6 +51,7 @@ export function startShell(
50
51
  let historyIndex: number | null = null;
51
52
  let historyDraft = "";
52
53
  let cwd = `/home/${authUser}`;
54
+ const shellEnv: ShellEnv = makeDefaultEnv(authUser, hostname);
53
55
  let nanoSession: NanoSession | null = null;
54
56
  let pendingSudo: PendingSudo | null = null;
55
57
  const buildCurrentPrompt = (): string => {
@@ -62,6 +64,21 @@ export function startShell(
62
64
  `[${sessionId}] Shell started for user '${authUser}' at ${remoteAddress}`,
63
65
  );
64
66
 
67
+ // Load .bashrc if it exists
68
+ void (async () => {
69
+ const bashrcPath = `/home/${authUser}/.bashrc`;
70
+ if (shell.vfs.exists(bashrcPath)) {
71
+ try {
72
+ const bashrc = shell.vfs.readFile(bashrcPath);
73
+ for (const line of bashrc.split("\n")) {
74
+ const l = line.trim();
75
+ if (!l || l.startsWith("#")) continue;
76
+ await runCommand(l, authUser, hostname, "shell", cwd, shell, undefined, shellEnv);
77
+ }
78
+ } catch { /* ignore bashrc errors */ }
79
+ }
80
+ })();
81
+
65
82
  function renderLine(): void {
66
83
  const prompt = buildCurrentPrompt();
67
84
  stream.write(`\r${prompt}${lineBuffer}\u001b[K`);
@@ -568,7 +585,7 @@ export function startShell(
568
585
 
569
586
  if (line.length > 0) {
570
587
  const result = await Promise.resolve(
571
- runCommand(line, authUser, hostname, "shell", cwd, shell),
588
+ runCommand(line, authUser, hostname, "shell", cwd, shell, undefined, shellEnv),
572
589
  );
573
590
 
574
591
  pushHistory(line);