snyk 1.1298.0 → 1.1298.2

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.
@@ -209431,8 +209431,8 @@ async function getImageArchive(targetImage, imageSavePath, username, password, p
209431
209431
  try {
209432
209432
  inspectResult = await getInspectResult(docker, targetImage);
209433
209433
  }
209434
- catch (_a) {
209435
- debug(`${targetImage} does not exist locally, proceeding to pull image.`);
209434
+ catch (error) {
209435
+ debug(`${targetImage} does not exist locally, proceeding to pull image.`, error.stack || error);
209436
209436
  }
209437
209437
  if (inspectResult === undefined) {
209438
209438
  const imageName = await pullImage(docker, targetImage, saveLocation, imageSavePath, username, password, platform);
@@ -212058,8 +212058,13 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions, options)
212058
212058
  }
212059
212059
  exports.extractArchive = extractArchive;
212060
212060
  function getLayersContentAndArchiveManifest(imageIndex, manifestCollection, indexFiles, configs, layers, options) {
212061
+ const filteredConfigs = configs.filter((config) => {
212062
+ return (config === null || config === void 0 ? void 0 : config.os) !== "unknown" || (config === null || config === void 0 ? void 0 : config.architecture) !== "unknown";
212063
+ });
212061
212064
  const platform = (options === null || options === void 0 ? void 0 : options.platform) ||
212062
- (configs.length === 1 ? (0, __1.getPlatformFromConfig)(configs[0]) : "linux/amd64");
212065
+ (filteredConfigs.length === 1
212066
+ ? (0, __1.getPlatformFromConfig)(filteredConfigs[0])
212067
+ : "linux/amd64");
212063
212068
  const platformInfo = getOciPlatformInfoFromOptionString(platform);
212064
212069
  // get manifest file first
212065
212070
  const manifest = getManifest(imageIndex, manifestCollection, indexFiles, platformInfo);
@@ -214587,16 +214592,16 @@ exports.streamToJson = streamToJson;
214587
214592
  Object.defineProperty(exports, "__esModule", ({ value: true }));
214588
214593
  exports.execute = void 0;
214589
214594
  const childProcess = __webpack_require__(32081);
214590
- const stateless_1 = __webpack_require__(11977);
214595
+ const shescape_1 = __webpack_require__(66710);
214591
214596
  function execute(command, args, options) {
214592
214597
  const spawnOptions = {
214593
- shell: process.platform !== "win32" ? "/bin/bash" : true,
214598
+ shell: true,
214594
214599
  env: { ...process.env },
214595
214600
  };
214596
214601
  if (options && options.cwd) {
214597
214602
  spawnOptions.cwd = options.cwd;
214598
214603
  }
214599
- args = (0, stateless_1.quoteAll)(args, { ...spawnOptions, flagProtection: false });
214604
+ args = (0, shescape_1.quoteAll)(args, spawnOptions);
214600
214605
  // Before spawning an external process, we look if we need to restore the system proxy configuration,
214601
214606
  // which overrides the cli internal proxy configuration.
214602
214607
  if (process.env.SNYK_SYSTEM_HTTP_PROXY !== undefined) {
@@ -219301,118 +219306,128 @@ module.exports.setGracefulCleanup = setGracefulCleanup;
219301
219306
 
219302
219307
  /***/ }),
219303
219308
 
219304
- /***/ 25190:
219309
+ /***/ 81918:
219305
219310
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
219306
219311
 
219307
- const isexe = __webpack_require__(31959)
219308
- const { join, delimiter, sep, posix } = __webpack_require__(71017)
219309
-
219310
- const isWindows = process.platform === 'win32'
219312
+ const isWindows = process.platform === 'win32' ||
219313
+ process.env.OSTYPE === 'cygwin' ||
219314
+ process.env.OSTYPE === 'msys'
219311
219315
 
219312
- // used to check for slashed in commands passed in. always checks for the posix
219313
- // seperator on all platforms, and checks for the current separator when not on
219314
- // a posix platform. don't use the isWindows check for this since that is mocked
219315
- // in tests but we still need the code to actually work when called. that is also
219316
- // why it is ignored from coverage.
219317
- /* istanbul ignore next */
219318
- const rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1'))
219319
- const rRel = new RegExp(`^\\.${rSlash.source}`)
219316
+ const path = __webpack_require__(71017)
219317
+ const COLON = isWindows ? ';' : ':'
219318
+ const isexe = __webpack_require__(31959)
219320
219319
 
219321
219320
  const getNotFoundError = (cmd) =>
219322
219321
  Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
219323
219322
 
219324
- const getPathInfo = (cmd, {
219325
- path: optPath = process.env.PATH,
219326
- pathExt: optPathExt = process.env.PATHEXT,
219327
- delimiter: optDelimiter = delimiter,
219328
- }) => {
219323
+ const getPathInfo = (cmd, opt) => {
219324
+ const colon = opt.colon || COLON
219325
+
219329
219326
  // If it has a slash, then we don't bother searching the pathenv.
219330
219327
  // just check the file itself, and that's it.
219331
- const pathEnv = cmd.match(rSlash) ? [''] : [
219332
- // windows always checks the cwd first
219333
- ...(isWindows ? [process.cwd()] : []),
219334
- ...(optPath || /* istanbul ignore next: very unusual */ '').split(optDelimiter),
219335
- ]
219328
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
219329
+ : (
219330
+ [
219331
+ // windows always checks the cwd first
219332
+ ...(isWindows ? [process.cwd()] : []),
219333
+ ...(opt.path || process.env.PATH ||
219334
+ /* istanbul ignore next: very unusual */ '').split(colon),
219335
+ ]
219336
+ )
219337
+ const pathExtExe = isWindows
219338
+ ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
219339
+ : ''
219340
+ const pathExt = isWindows ? pathExtExe.split(colon) : ['']
219336
219341
 
219337
219342
  if (isWindows) {
219338
- const pathExtExe = optPathExt ||
219339
- ['.EXE', '.CMD', '.BAT', '.COM'].join(optDelimiter)
219340
- const pathExt = pathExtExe.split(optDelimiter).reduce((acc, item) => {
219341
- acc.push(item)
219342
- acc.push(item.toLowerCase())
219343
- return acc
219344
- }, [])
219345
- if (cmd.includes('.') && pathExt[0] !== '') {
219343
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
219346
219344
  pathExt.unshift('')
219347
- }
219348
- return { pathEnv, pathExt, pathExtExe }
219349
219345
  }
219350
219346
 
219351
- return { pathEnv, pathExt: [''] }
219347
+ return {
219348
+ pathEnv,
219349
+ pathExt,
219350
+ pathExtExe,
219351
+ }
219352
219352
  }
219353
219353
 
219354
- const getPathPart = (raw, cmd) => {
219355
- const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw
219356
- const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : ''
219357
- return prefix + join(pathPart, cmd)
219358
- }
219354
+ const which = (cmd, opt, cb) => {
219355
+ if (typeof opt === 'function') {
219356
+ cb = opt
219357
+ opt = {}
219358
+ }
219359
+ if (!opt)
219360
+ opt = {}
219359
219361
 
219360
- const which = async (cmd, opt = {}) => {
219361
219362
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
219362
219363
  const found = []
219363
219364
 
219364
- for (const envPart of pathEnv) {
219365
- const p = getPathPart(envPart, cmd)
219365
+ const step = i => new Promise((resolve, reject) => {
219366
+ if (i === pathEnv.length)
219367
+ return opt.all && found.length ? resolve(found)
219368
+ : reject(getNotFoundError(cmd))
219366
219369
 
219367
- for (const ext of pathExt) {
219368
- const withExt = p + ext
219369
- const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true })
219370
- if (is) {
219371
- if (!opt.all) {
219372
- return withExt
219373
- }
219374
- found.push(withExt)
219375
- }
219376
- }
219377
- }
219370
+ const ppRaw = pathEnv[i]
219371
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
219378
219372
 
219379
- if (opt.all && found.length) {
219380
- return found
219381
- }
219373
+ const pCmd = path.join(pathPart, cmd)
219374
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
219375
+ : pCmd
219382
219376
 
219383
- if (opt.nothrow) {
219384
- return null
219385
- }
219377
+ resolve(subStep(p, i, 0))
219378
+ })
219386
219379
 
219387
- throw getNotFoundError(cmd)
219380
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
219381
+ if (ii === pathExt.length)
219382
+ return resolve(step(i + 1))
219383
+ const ext = pathExt[ii]
219384
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
219385
+ if (!er && is) {
219386
+ if (opt.all)
219387
+ found.push(p + ext)
219388
+ else
219389
+ return resolve(p + ext)
219390
+ }
219391
+ return resolve(subStep(p, i, ii + 1))
219392
+ })
219393
+ })
219394
+
219395
+ return cb ? step(0).then(res => cb(null, res), cb) : step(0)
219388
219396
  }
219389
219397
 
219390
- const whichSync = (cmd, opt = {}) => {
219398
+ const whichSync = (cmd, opt) => {
219399
+ opt = opt || {}
219400
+
219391
219401
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
219392
219402
  const found = []
219393
219403
 
219394
- for (const pathEnvPart of pathEnv) {
219395
- const p = getPathPart(pathEnvPart, cmd)
219404
+ for (let i = 0; i < pathEnv.length; i ++) {
219405
+ const ppRaw = pathEnv[i]
219406
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
219396
219407
 
219397
- for (const ext of pathExt) {
219398
- const withExt = p + ext
219399
- const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true })
219400
- if (is) {
219401
- if (!opt.all) {
219402
- return withExt
219408
+ const pCmd = path.join(pathPart, cmd)
219409
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
219410
+ : pCmd
219411
+
219412
+ for (let j = 0; j < pathExt.length; j ++) {
219413
+ const cur = p + pathExt[j]
219414
+ try {
219415
+ const is = isexe.sync(cur, { pathExt: pathExtExe })
219416
+ if (is) {
219417
+ if (opt.all)
219418
+ found.push(cur)
219419
+ else
219420
+ return cur
219403
219421
  }
219404
- found.push(withExt)
219405
- }
219422
+ } catch (ex) {}
219406
219423
  }
219407
219424
  }
219408
219425
 
219409
- if (opt.all && found.length) {
219426
+ if (opt.all && found.length)
219410
219427
  return found
219411
- }
219412
219428
 
219413
- if (opt.nothrow) {
219429
+ if (opt.nothrow)
219414
219430
  return null
219415
- }
219416
219431
 
219417
219432
  throw getNotFoundError(cmd)
219418
219433
  }
@@ -367744,18 +367759,18 @@ exports["default"] = version;
367744
367759
 
367745
367760
  /***/ }),
367746
367761
 
367747
- /***/ 11977:
367762
+ /***/ 66710:
367748
367763
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
367749
367764
 
367750
367765
  "use strict";
367751
367766
 
367752
367767
 
367753
- var os = __webpack_require__(70612);
367754
- var process = __webpack_require__(97742);
367755
- var fs = __webpack_require__(87561);
367756
- var path = __webpack_require__(49411);
367757
- var which = __webpack_require__(25190);
367758
- var node_util = __webpack_require__(47261);
367768
+ var os = __webpack_require__(22037);
367769
+ var process = __webpack_require__(77282);
367770
+ var fs = __webpack_require__(57147);
367771
+ var path = __webpack_require__(71017);
367772
+ var which = __webpack_require__(81918);
367773
+ var util = __webpack_require__(73837);
367759
367774
 
367760
367775
  function _interopNamespaceDefault(e) {
367761
367776
  var n = Object.create(null);
@@ -367777,6 +367792,56 @@ function _interopNamespaceDefault(e) {
367777
367792
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
367778
367793
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
367779
367794
 
367795
+ /**
367796
+ * @overview Provides functionality related to working with executables.
367797
+ * @license MPL-2.0
367798
+ */
367799
+
367800
+ /**
367801
+ * Resolves the location of an executable given an arbitrary valid string
367802
+ * representation of that executable.
367803
+ *
367804
+ * To obtain the location of the executable this function (if necessary):
367805
+ * - Expands the provided string to an absolute path.
367806
+ * - Follows symbolic links.
367807
+ *
367808
+ * @param {object} args The arguments for this function.
367809
+ * @param {object} args.env The environment variables.
367810
+ * @param {string} args.executable A string representation of the executable.
367811
+ * @param {object} deps The dependencies for this function.
367812
+ * @param {Function} deps.exists A function to check if a file exists.
367813
+ * @param {Function} deps.readlink A function to resolve (sym)links.
367814
+ * @param {Function} deps.which A function to perform a `which(1)`-like lookup.
367815
+ * @returns {string} The full path to the binary of the executable.
367816
+ */
367817
+ function resolveExecutable(
367818
+ { env, executable },
367819
+ { exists, readlink, which },
367820
+ ) {
367821
+ try {
367822
+ executable = which(executable, { path: env.PATH || env.Path });
367823
+ } catch (_) {
367824
+ // For backwards compatibility return the executable even if its location
367825
+ // cannot be obtained
367826
+ return executable;
367827
+ }
367828
+
367829
+ if (!exists(executable)) {
367830
+ // For backwards compatibility return the executable even if there exists no
367831
+ // file at the specified path
367832
+ return executable;
367833
+ }
367834
+
367835
+ try {
367836
+ executable = readlink(executable);
367837
+ } catch (_) {
367838
+ // An error will be thrown if the executable is not a (sym)link, this is not
367839
+ // a problem so the error is ignored
367840
+ }
367841
+
367842
+ return executable;
367843
+ }
367844
+
367780
367845
  /**
367781
367846
  * @overview Provides reflection functionality.
367782
367847
  * @license MPL-2.0
@@ -367807,20 +367872,6 @@ const typeofFunction = "function";
367807
367872
  */
367808
367873
  const typeofString = "string";
367809
367874
 
367810
- /**
367811
- * Check if the given object has the given property as an own property.
367812
- *
367813
- * This custom function is used over `Object.hasOwn` because that isn't
367814
- * available in all supported Node.js versions.
367815
- *
367816
- * @param {object} object The object of interest.
367817
- * @param {string} property The property of interest.
367818
- * @returns {boolean} `true` if property is an own-property, `false` otherwise.
367819
- */
367820
- function hasOwn(object, property) {
367821
- return Object.prototype.hasOwnProperty.call(object, property);
367822
- }
367823
-
367824
367875
  /**
367825
367876
  * Checks if a value can be converted into a string and converts it if possible.
367826
367877
  *
@@ -367875,67 +367926,14 @@ function isString(value) {
367875
367926
  }
367876
367927
 
367877
367928
  /**
367878
- * @overview Provides functionality related to working with executables.
367879
- * @license MPL-2.0
367880
- */
367881
-
367882
-
367883
- /**
367884
- * Build error messages for when executables cannot be found.
367929
+ * Converts the provided value into an array if it is not already an array and
367930
+ * returns the array.
367885
367931
  *
367886
- * @param {string} executable The executable being looked up.
367887
- * @returns {string} The executable not found error message.
367932
+ * @param {Array | any} value The value to convert to an array if necessary.
367933
+ * @returns {Array} An array containing `value` or `value` itself.
367888
367934
  */
367889
- function notFoundError(executable) {
367890
- return `No executable could be found for ${executable}`;
367891
- }
367892
-
367893
- /**
367894
- * Resolves the location of an executable given an arbitrary valid string
367895
- * representation of that executable.
367896
- *
367897
- * To obtain the location of the executable this function (if necessary):
367898
- * - Expands the provided string to an absolute path.
367899
- * - Follows symbolic links.
367900
- *
367901
- * @param {object} args The arguments for this function.
367902
- * @param {Object<string, string>} args.env The environment variables.
367903
- * @param {string} args.executable A string representation of the executable.
367904
- * @param {object} deps The dependencies for this function.
367905
- * @param {Function} deps.exists A function to check if a file exists.
367906
- * @param {Function} deps.readlink A function to resolve (sym)links.
367907
- * @param {Function} deps.which A function to perform a `which(1)`-like lookup.
367908
- * @returns {string} The full path to the binary of the executable.
367909
- * @throws {Error} If the executable could not be found.
367910
- */
367911
- function resolveExecutable(
367912
- { env, executable },
367913
- { exists, readlink, which },
367914
- ) {
367915
- let resolved = executable;
367916
- try {
367917
- const path = hasOwn(env, "PATH")
367918
- ? env.PATH
367919
- : hasOwn(env, "Path")
367920
- ? env.Path
367921
- : undefined;
367922
- resolved = which(resolved, { path });
367923
- } catch (_) {
367924
- throw new Error(notFoundError(executable));
367925
- }
367926
-
367927
- if (!exists(resolved)) {
367928
- throw new Error(notFoundError(executable));
367929
- }
367930
-
367931
- try {
367932
- resolved = readlink(resolved);
367933
- } catch (_) {
367934
- // An error will be thrown if the executable is not a (sym)link, this is not
367935
- // a problem so the error is ignored
367936
- }
367937
-
367938
- return resolved;
367935
+ function toArrayIfNecessary(value) {
367936
+ return Array.isArray(value) ? value : [value];
367939
367937
  }
367940
367938
 
367941
367939
  /**
@@ -367944,63 +367942,30 @@ function resolveExecutable(
367944
367942
  */
367945
367943
 
367946
367944
 
367947
- /**
367948
- * The identifier for 'no shell' or the absence of a shell.
367949
- *
367950
- * @constant
367951
- * @type {symbol}
367952
- */
367953
- const noShell = Symbol();
367954
-
367955
- /**
367956
- * Build error messages for unsupported shells.
367957
- *
367958
- * @param {string} shellName The full name of a shell.
367959
- * @returns {string} The unsupported shell error message.
367960
- */
367961
- function unsupportedError$2(shellName) {
367962
- return `Shescape does not support the shell ${shellName}`;
367963
- }
367964
-
367965
367945
  /**
367966
367946
  * Parses options provided to shescape.
367967
367947
  *
367968
367948
  * @param {object} args The arguments for this function.
367969
- * @param {Object<string, string>} args.env The environment variables.
367949
+ * @param {object} args.env The environment variables.
367970
367950
  * @param {object} args.options The options for escaping.
367951
+ * @param {boolean} [args.options.flagProtection] Is flag protection enabled.
367952
+ * @param {boolean} [args.options.interpolation] Is interpolation enabled.
367953
+ * @param {boolean | string} [args.options.shell] The shell to escape for.
367971
367954
  * @param {object} deps The dependencies for this function.
367972
367955
  * @param {Function} deps.getDefaultShell Function to get the default shell.
367973
367956
  * @param {Function} deps.getShellName Function to get the name of a shell.
367974
- * @param {Function} deps.isShellSupported Function to see if a shell is usable.
367975
367957
  * @returns {object} The parsed arguments.
367976
- * @throws {Error} The shell is not supported or could not be found.
367977
367958
  */
367978
367959
  function parseOptions(
367979
- { env, options },
367980
- { getDefaultShell, getShellName, isShellSupported },
367960
+ { env, options: { flagProtection, interpolation, shell } },
367961
+ { getDefaultShell, getShellName },
367981
367962
  ) {
367982
- let flagProtection = hasOwn(options, "flagProtection")
367983
- ? options.flagProtection
367984
- : undefined;
367985
- let shell = hasOwn(options, "shell") ? options.shell : undefined;
367986
-
367987
- flagProtection =
367988
- flagProtection === undefined ? true : flagProtection ? true : false;
367989
-
367990
- let shellName = noShell;
367991
- if (shell !== false) {
367992
- if (!isString(shell)) {
367993
- shell = getDefaultShell({ env });
367994
- }
367995
-
367996
- shellName = getShellName({ env, shell }, { resolveExecutable });
367997
- }
367998
-
367999
- if (!isShellSupported(shellName)) {
368000
- throw new Error(unsupportedError$2(shellName));
368001
- }
367963
+ flagProtection = flagProtection ? true : false;
367964
+ interpolation = interpolation ? true : false;
367965
+ shell = isString(shell) ? shell : getDefaultShell({ env });
368002
367966
 
368003
- return { flagProtection, shellName };
367967
+ const shellName = getShellName({ env, shell }, { resolveExecutable });
367968
+ return { flagProtection, interpolation, shellName };
368004
367969
  }
368005
367970
 
368006
367971
  /**
@@ -368009,12 +367974,12 @@ function parseOptions(
368009
367974
  */
368010
367975
 
368011
367976
  /**
368012
- * Escape an argument for use in Bash.
367977
+ * Escape an argument for use in Bash when interpolation is active.
368013
367978
  *
368014
367979
  * @param {string} arg The argument to escape.
368015
367980
  * @returns {string} The escaped argument.
368016
367981
  */
368017
- function escapeArg$7(arg) {
367982
+ function escapeArgForInterpolation$5(arg) {
368018
367983
  return arg
368019
367984
  .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
368020
367985
  .replace(/\n/gu, " ")
@@ -368025,14 +367990,31 @@ function escapeArg$7(arg) {
368025
367990
  .replace(/([\t ])/gu, "\\$1");
368026
367991
  }
368027
367992
 
367993
+ /**
367994
+ * Escape an argument for use in Bash when the argument is not being quoted (but
367995
+ * interpolation is inactive).
367996
+ *
367997
+ * @param {string} arg The argument to escape.
367998
+ * @returns {string} The escaped argument.
367999
+ */
368000
+ function escapeArgForNoInterpolation$5(arg) {
368001
+ return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
368002
+ }
368003
+
368028
368004
  /**
368029
368005
  * Returns a function to escape arguments for use in Bash for the given use
368030
368006
  * case.
368031
368007
  *
368008
+ * @param {object} options The options for escaping arguments.
368009
+ * @param {boolean} options.interpolation Is interpolation enabled.
368032
368010
  * @returns {Function} A function to escape arguments.
368033
368011
  */
368034
- function getEscapeFunction$9() {
368035
- return escapeArg$7;
368012
+ function getEscapeFunction$7(options) {
368013
+ if (options.interpolation) {
368014
+ return escapeArgForInterpolation$5;
368015
+ } else {
368016
+ return escapeArgForNoInterpolation$5;
368017
+ }
368036
368018
  }
368037
368019
 
368038
368020
  /**
@@ -368063,7 +368045,7 @@ function quoteArg$5(arg) {
368063
368045
  *
368064
368046
  * @returns {Function[]} A function pair to escape & quote arguments.
368065
368047
  */
368066
- function getQuoteFunction$9() {
368048
+ function getQuoteFunction$7() {
368067
368049
  return [escapeArgForQuoted$5, quoteArg$5];
368068
368050
  }
368069
368051
 
@@ -368074,7 +368056,7 @@ function getQuoteFunction$9() {
368074
368056
  * @param {string} arg The argument to update.
368075
368057
  * @returns {string} The updated argument.
368076
368058
  */
368077
- function stripFlagPrefix$7(arg) {
368059
+ function stripFlagPrefix$5(arg) {
368078
368060
  return arg.replace(/^-+/gu, "");
368079
368061
  }
368080
368062
 
@@ -368083,8 +368065,8 @@ function stripFlagPrefix$7(arg) {
368083
368065
  *
368084
368066
  * @returns {Function} A function to protect against flag injection.
368085
368067
  */
368086
- function getFlagProtectionFunction$9() {
368087
- return stripFlagPrefix$7;
368068
+ function getFlagProtectionFunction$7() {
368069
+ return stripFlagPrefix$5;
368088
368070
  }
368089
368071
 
368090
368072
  /**
@@ -368094,13 +368076,13 @@ function getFlagProtectionFunction$9() {
368094
368076
 
368095
368077
 
368096
368078
  /**
368097
- * Escape an argument for use in csh.
368079
+ * Escape an argument for use in csh when interpolation is active.
368098
368080
  *
368099
368081
  * @param {string} arg The argument to escape.
368100
368082
  * @returns {string} The escaped argument.
368101
368083
  */
368102
- function escapeArg$6(arg) {
368103
- const textEncoder = new node_util.TextEncoder();
368084
+ function escapeArgForInterpolation$4(arg) {
368085
+ const textEncoder = new util.TextEncoder();
368104
368086
  return arg
368105
368087
  .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
368106
368088
  .replace(/\n/gu, " ")
@@ -368121,13 +368103,34 @@ function escapeArg$6(arg) {
368121
368103
  .join("");
368122
368104
  }
368123
368105
 
368106
+ /**
368107
+ * Escape an argument for use in csh when the argument is not being quoted (but
368108
+ * interpolation is inactive).
368109
+ *
368110
+ * @param {string} arg The argument to escape.
368111
+ * @returns {string} The escaped argument.
368112
+ */
368113
+ function escapeArgForNoInterpolation$4(arg) {
368114
+ return arg
368115
+ .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
368116
+ .replace(/\n/gu, " ")
368117
+ .replace(/\\!$/gu, "\\\\!")
368118
+ .replace(/!(?!$)/gu, "\\!");
368119
+ }
368120
+
368124
368121
  /**
368125
368122
  * Returns a function to escape arguments for use in csh for the given use case.
368126
368123
  *
368124
+ * @param {object} options The options for escaping arguments.
368125
+ * @param {boolean} options.interpolation Is interpolation enabled.
368127
368126
  * @returns {Function} A function to escape arguments.
368128
368127
  */
368129
- function getEscapeFunction$8() {
368130
- return escapeArg$6;
368128
+ function getEscapeFunction$6(options) {
368129
+ if (options.interpolation) {
368130
+ return escapeArgForInterpolation$4;
368131
+ } else {
368132
+ return escapeArgForNoInterpolation$4;
368133
+ }
368131
368134
  }
368132
368135
 
368133
368136
  /**
@@ -368160,7 +368163,7 @@ function quoteArg$4(arg) {
368160
368163
  *
368161
368164
  * @returns {Function[]} A function pair to escape & quote arguments.
368162
368165
  */
368163
- function getQuoteFunction$8() {
368166
+ function getQuoteFunction$6() {
368164
368167
  return [escapeArgForQuoted$4, quoteArg$4];
368165
368168
  }
368166
368169
 
@@ -368171,7 +368174,7 @@ function getQuoteFunction$8() {
368171
368174
  * @param {string} arg The argument to update.
368172
368175
  * @returns {string} The updated argument.
368173
368176
  */
368174
- function stripFlagPrefix$6(arg) {
368177
+ function stripFlagPrefix$4(arg) {
368175
368178
  return arg.replace(/^-+/gu, "");
368176
368179
  }
368177
368180
 
@@ -368180,8 +368183,8 @@ function stripFlagPrefix$6(arg) {
368180
368183
  *
368181
368184
  * @returns {Function} A function to protect against flag injection.
368182
368185
  */
368183
- function getFlagProtectionFunction$8() {
368184
- return stripFlagPrefix$6;
368186
+ function getFlagProtectionFunction$6() {
368187
+ return stripFlagPrefix$4;
368185
368188
  }
368186
368189
 
368187
368190
  /**
@@ -368190,12 +368193,12 @@ function getFlagProtectionFunction$8() {
368190
368193
  */
368191
368194
 
368192
368195
  /**
368193
- * Escape an argument for use in Dash.
368196
+ * Escape an argument for use in Dash when interpolation is active.
368194
368197
  *
368195
368198
  * @param {string} arg The argument to escape.
368196
368199
  * @returns {string} The escaped argument.
368197
368200
  */
368198
- function escapeArg$5(arg) {
368201
+ function escapeArgForInterpolation$3(arg) {
368199
368202
  return arg
368200
368203
  .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
368201
368204
  .replace(/\n/gu, " ")
@@ -368205,14 +368208,31 @@ function escapeArg$5(arg) {
368205
368208
  .replace(/([\t ])/gu, "\\$1");
368206
368209
  }
368207
368210
 
368211
+ /**
368212
+ * Escape an argument for use in Dash when the argument is not being quoted (but
368213
+ * interpolation is inactive).
368214
+ *
368215
+ * @param {string} arg The argument to escape.
368216
+ * @returns {string} The escaped argument.
368217
+ */
368218
+ function escapeArgForNoInterpolation$3(arg) {
368219
+ return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
368220
+ }
368221
+
368208
368222
  /**
368209
368223
  * Returns a function to escape arguments for use in Dash for the given use
368210
368224
  * case.
368211
368225
  *
368226
+ * @param {object} options The options for escaping arguments.
368227
+ * @param {boolean} options.interpolation Is interpolation enabled.
368212
368228
  * @returns {Function} A function to escape arguments.
368213
368229
  */
368214
- function getEscapeFunction$7() {
368215
- return escapeArg$5;
368230
+ function getEscapeFunction$5(options) {
368231
+ if (options.interpolation) {
368232
+ return escapeArgForInterpolation$3;
368233
+ } else {
368234
+ return escapeArgForNoInterpolation$3;
368235
+ }
368216
368236
  }
368217
368237
 
368218
368238
  /**
@@ -368243,7 +368263,7 @@ function quoteArg$3(arg) {
368243
368263
  *
368244
368264
  * @returns {Function[]} A function pair to escape & quote arguments.
368245
368265
  */
368246
- function getQuoteFunction$7() {
368266
+ function getQuoteFunction$5() {
368247
368267
  return [escapeArgForQuoted$3, quoteArg$3];
368248
368268
  }
368249
368269
 
@@ -368254,7 +368274,7 @@ function getQuoteFunction$7() {
368254
368274
  * @param {string} arg The argument to update.
368255
368275
  * @returns {string} The updated argument.
368256
368276
  */
368257
- function stripFlagPrefix$5(arg) {
368277
+ function stripFlagPrefix$3(arg) {
368258
368278
  return arg.replace(/^-+/gu, "");
368259
368279
  }
368260
368280
 
@@ -368263,78 +368283,8 @@ function stripFlagPrefix$5(arg) {
368263
368283
  *
368264
368284
  * @returns {Function} A function to protect against flag injection.
368265
368285
  */
368266
- function getFlagProtectionFunction$7() {
368267
- return stripFlagPrefix$5;
368268
- }
368269
-
368270
- /**
368271
- * @overview Provides functionality for shell-less escaping on Unix systems.
368272
- * @license MPL-2.0
368273
- */
368274
-
368275
- /**
368276
- * The error message for use of quoting functionality.
368277
- *
368278
- * @constant
368279
- * @type {string}
368280
- */
368281
- const unsupportedError$1 = "Quoting is not supported when no shell is used";
368282
-
368283
- /**
368284
- * Escape an argument for shell-less use.
368285
- *
368286
- * @param {string} arg The argument to escape.
368287
- * @returns {string} The escaped argument.
368288
- */
368289
- function escapeArg$4(arg) {
368290
- return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
368291
- }
368292
-
368293
- /**
368294
- * Returns a function to escape arguments for shell-less use.
368295
- *
368296
- * @returns {Function} A function to escape arguments.
368297
- */
368298
- function getEscapeFunction$6() {
368299
- return escapeArg$4;
368300
- }
368301
-
368302
- /**
368303
- * Returns the provided value.
368304
- *
368305
- * @throws {Error} Always.
368306
- */
368307
- function unsupported$1() {
368308
- throw new Error(unsupportedError$1);
368309
- }
368310
-
368311
- /**
368312
- * Returns a pair of functions that will indicate this operation is unsupported.
368313
- *
368314
- * @returns {Function[]} A pair of functions.
368315
- */
368316
- function getQuoteFunction$6() {
368317
- return [unsupported$1, unsupported$1];
368318
- }
368319
-
368320
- /**
368321
- * Remove any prefix from the provided argument that might be interpreted as a
368322
- * flag on Unix systems.
368323
- *
368324
- * @param {string} arg The argument to update.
368325
- * @returns {string} The updated argument.
368326
- */
368327
- function stripFlagPrefix$4(arg) {
368328
- return arg.replace(/^-+/gu, "");
368329
- }
368330
-
368331
- /**
368332
- * Returns a function to protect against flag injection for Unix systems.
368333
- *
368334
- * @returns {Function} A function to protect against flag injection.
368335
- */
368336
- function getFlagProtectionFunction$6() {
368337
- return stripFlagPrefix$4;
368286
+ function getFlagProtectionFunction$5() {
368287
+ return stripFlagPrefix$3;
368338
368288
  }
368339
368289
 
368340
368290
  /**
@@ -368343,12 +368293,12 @@ function getFlagProtectionFunction$6() {
368343
368293
  */
368344
368294
 
368345
368295
  /**
368346
- * Escape an argument for use in Zsh.
368296
+ * Escape an argument for use in Zsh when interpolation is active.
368347
368297
  *
368348
368298
  * @param {string} arg The argument to escape.
368349
368299
  * @returns {string} The escaped argument.
368350
368300
  */
368351
- function escapeArg$3(arg) {
368301
+ function escapeArgForInterpolation$2(arg) {
368352
368302
  return arg
368353
368303
  .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
368354
368304
  .replace(/\n/gu, " ")
@@ -368358,13 +368308,30 @@ function escapeArg$3(arg) {
368358
368308
  .replace(/([\t ])/gu, "\\$1");
368359
368309
  }
368360
368310
 
368311
+ /**
368312
+ * Escape an argument for use in Zsh when the argument is not being quoted (but
368313
+ * interpolation is inactive).
368314
+ *
368315
+ * @param {string} arg The argument to escape.
368316
+ * @returns {string} The escaped argument.
368317
+ */
368318
+ function escapeArgForNoInterpolation$2(arg) {
368319
+ return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
368320
+ }
368321
+
368361
368322
  /**
368362
368323
  * Returns a function to escape arguments for use in Zsh for the given use case.
368363
368324
  *
368325
+ * @param {object} options The options for escaping arguments.
368326
+ * @param {boolean} options.interpolation Is interpolation enabled.
368364
368327
  * @returns {Function} A function to escape arguments.
368365
368328
  */
368366
- function getEscapeFunction$5() {
368367
- return escapeArg$3;
368329
+ function getEscapeFunction$4(options) {
368330
+ if (options.interpolation) {
368331
+ return escapeArgForInterpolation$2;
368332
+ } else {
368333
+ return escapeArgForNoInterpolation$2;
368334
+ }
368368
368335
  }
368369
368336
 
368370
368337
  /**
@@ -368395,7 +368362,7 @@ function quoteArg$2(arg) {
368395
368362
  *
368396
368363
  * @returns {Function[]} A function pair to escape & quote arguments.
368397
368364
  */
368398
- function getQuoteFunction$5() {
368365
+ function getQuoteFunction$4() {
368399
368366
  return [escapeArgForQuoted$2, quoteArg$2];
368400
368367
  }
368401
368368
 
@@ -368406,7 +368373,7 @@ function getQuoteFunction$5() {
368406
368373
  * @param {string} arg The argument to update.
368407
368374
  * @returns {string} The updated argument.
368408
368375
  */
368409
- function stripFlagPrefix$3(arg) {
368376
+ function stripFlagPrefix$2(arg) {
368410
368377
  return arg.replace(/^-+/gu, "");
368411
368378
  }
368412
368379
 
@@ -368415,8 +368382,8 @@ function stripFlagPrefix$3(arg) {
368415
368382
  *
368416
368383
  * @returns {Function} A function to protect against flag injection.
368417
368384
  */
368418
- function getFlagProtectionFunction$5() {
368419
- return stripFlagPrefix$3;
368385
+ function getFlagProtectionFunction$4() {
368386
+ return stripFlagPrefix$2;
368420
368387
  }
368421
368388
 
368422
368389
  /**
@@ -368472,21 +368439,21 @@ function getDefaultShell$1() {
368472
368439
  /**
368473
368440
  * Returns a function to escape arguments for use in a particular shell.
368474
368441
  *
368475
- * @param {string | symbol} shellName The name of a Unix shell.
368442
+ * @param {string} shellName The name of a Unix shell.
368443
+ * @param {object} options The options for escaping arguments.
368444
+ * @param {boolean} options.interpolation Is interpolation enabled.
368476
368445
  * @returns {Function | undefined} A function to escape arguments.
368477
368446
  */
368478
- function getEscapeFunction$4(shellName) {
368447
+ function getEscapeFunction$3(shellName, options) {
368479
368448
  switch (shellName) {
368480
- case noShell:
368481
- return getEscapeFunction$6();
368482
368449
  case binBash:
368483
- return getEscapeFunction$9();
368450
+ return getEscapeFunction$7(options);
368484
368451
  case binCsh:
368485
- return getEscapeFunction$8();
368452
+ return getEscapeFunction$6(options);
368486
368453
  case binDash:
368487
- return getEscapeFunction$7();
368454
+ return getEscapeFunction$5(options);
368488
368455
  case binZsh:
368489
- return getEscapeFunction$5();
368456
+ return getEscapeFunction$4(options);
368490
368457
  }
368491
368458
  }
368492
368459
 
@@ -368494,42 +368461,38 @@ function getEscapeFunction$4(shellName) {
368494
368461
  * Returns a pair of functions to escape and quote arguments for use in a
368495
368462
  * particular shell.
368496
368463
  *
368497
- * @param {string | symbol} shellName The name of a Unix shell.
368464
+ * @param {string} shellName The name of a Unix shell.
368498
368465
  * @returns {Function[] | undefined} A function pair to escape & quote arguments.
368499
368466
  */
368500
- function getQuoteFunction$4(shellName) {
368467
+ function getQuoteFunction$3(shellName) {
368501
368468
  switch (shellName) {
368502
- case noShell:
368503
- return getQuoteFunction$6();
368504
368469
  case binBash:
368505
- return getQuoteFunction$9();
368470
+ return getQuoteFunction$7();
368506
368471
  case binCsh:
368507
- return getQuoteFunction$8();
368472
+ return getQuoteFunction$6();
368508
368473
  case binDash:
368509
- return getQuoteFunction$7();
368510
- case binZsh:
368511
368474
  return getQuoteFunction$5();
368475
+ case binZsh:
368476
+ return getQuoteFunction$4();
368512
368477
  }
368513
368478
  }
368514
368479
 
368515
368480
  /**
368516
368481
  * Returns a function to protect against flag injection.
368517
368482
  *
368518
- * @param {string | symbol} shellName The name of a Unix shell.
368483
+ * @param {string} shellName The name of a Unix shell.
368519
368484
  * @returns {Function | undefined} A function to protect against flag injection.
368520
368485
  */
368521
- function getFlagProtectionFunction$4(shellName) {
368486
+ function getFlagProtectionFunction$3(shellName) {
368522
368487
  switch (shellName) {
368523
- case noShell:
368524
- return getFlagProtectionFunction$6();
368525
368488
  case binBash:
368526
- return getFlagProtectionFunction$9();
368489
+ return getFlagProtectionFunction$7();
368527
368490
  case binCsh:
368528
- return getFlagProtectionFunction$8();
368491
+ return getFlagProtectionFunction$6();
368529
368492
  case binDash:
368530
- return getFlagProtectionFunction$7();
368531
- case binZsh:
368532
368493
  return getFlagProtectionFunction$5();
368494
+ case binZsh:
368495
+ return getFlagProtectionFunction$4();
368533
368496
  }
368534
368497
  }
368535
368498
 
@@ -368537,7 +368500,7 @@ function getFlagProtectionFunction$4(shellName) {
368537
368500
  * Determines the name of the shell identified by a file path or file name.
368538
368501
  *
368539
368502
  * @param {object} args The arguments for this function.
368540
- * @param {Object<string, string>} args.env The environment variables.
368503
+ * @param {object} args.env The environment variables.
368541
368504
  * @param {string} args.shell The name or path of the shell.
368542
368505
  * @param {object} deps The dependencies for this function.
368543
368506
  * @param {Function} deps.resolveExecutable Resolve the path to an executable.
@@ -368550,27 +368513,20 @@ function getShellName$1({ env, shell }, { resolveExecutable }) {
368550
368513
  );
368551
368514
 
368552
368515
  const shellName = path__namespace.basename(shell);
368553
- return shellName;
368554
- }
368516
+ if (getEscapeFunction$3(shellName, {}) === undefined) {
368517
+ return binBash;
368518
+ }
368555
368519
 
368556
- /**
368557
- * Checks if the given shell is supported on Unix or not.
368558
- *
368559
- * @param {string} shellName The name of a Unix shell.
368560
- * @returns {boolean} `true` if the shell is supported, `false` otherwise.
368561
- */
368562
- function isShellSupported$1(shellName) {
368563
- return getEscapeFunction$4(shellName) !== undefined;
368520
+ return shellName;
368564
368521
  }
368565
368522
 
368566
368523
  var unix = /*#__PURE__*/Object.freeze({
368567
368524
  __proto__: null,
368568
368525
  getDefaultShell: getDefaultShell$1,
368569
- getEscapeFunction: getEscapeFunction$4,
368570
- getFlagProtectionFunction: getFlagProtectionFunction$4,
368571
- getQuoteFunction: getQuoteFunction$4,
368572
- getShellName: getShellName$1,
368573
- isShellSupported: isShellSupported$1
368526
+ getEscapeFunction: getEscapeFunction$3,
368527
+ getFlagProtectionFunction: getFlagProtectionFunction$3,
368528
+ getQuoteFunction: getQuoteFunction$3,
368529
+ getShellName: getShellName$1
368574
368530
  });
368575
368531
 
368576
368532
  /**
@@ -368579,12 +368535,12 @@ var unix = /*#__PURE__*/Object.freeze({
368579
368535
  */
368580
368536
 
368581
368537
  /**
368582
- * Escape an argument for use in CMD.
368538
+ * Escape an argument for use in CMD when interpolation is active.
368583
368539
  *
368584
368540
  * @param {string} arg The argument to escape.
368585
368541
  * @returns {string} The escaped argument.
368586
368542
  */
368587
- function escapeArg$2(arg) {
368543
+ function escapeArgForInterpolation$1(arg) {
368588
368544
  let shouldEscapeSpecialChar = true;
368589
368545
  return arg
368590
368546
  .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
@@ -368610,13 +368566,30 @@ function escapeArg$2(arg) {
368610
368566
  .join("");
368611
368567
  }
368612
368568
 
368569
+ /**
368570
+ * Escape an argument for use in CMD when the argument is not being quoted (but
368571
+ * interpolation is inactive).
368572
+ *
368573
+ * @param {string} arg The argument to escape.
368574
+ * @returns {string} The escaped argument.
368575
+ */
368576
+ function escapeArgForNoInterpolation$1(arg) {
368577
+ return arg.replace(/[\0\u0008\r\u001B\u009B]/gu, "").replace(/\n/gu, " ");
368578
+ }
368579
+
368613
368580
  /**
368614
368581
  * Returns a function to escape arguments for use in CMD for the given use case.
368615
368582
  *
368583
+ * @param {object} options The options for escaping arguments.
368584
+ * @param {boolean} options.interpolation Is interpolation enabled.
368616
368585
  * @returns {Function} A function to escape arguments.
368617
368586
  */
368618
- function getEscapeFunction$3() {
368619
- return escapeArg$2;
368587
+ function getEscapeFunction$2(options) {
368588
+ if (options.interpolation) {
368589
+ return escapeArgForInterpolation$1;
368590
+ } else {
368591
+ return escapeArgForNoInterpolation$1;
368592
+ }
368620
368593
  }
368621
368594
 
368622
368595
  /**
@@ -368626,7 +368599,10 @@ function getEscapeFunction$3() {
368626
368599
  * @returns {string} The escaped argument.
368627
368600
  */
368628
368601
  function escapeArgForQuoted$1(arg) {
368629
- return escapeArg$2(arg).replace(/(?<!\\)(\\*)([\t ])/gu, "$1$1$2");
368602
+ return escapeArgForInterpolation$1(arg).replace(
368603
+ /(?<!\\)(\\*)([\t ])/gu,
368604
+ "$1$1$2",
368605
+ );
368630
368606
  }
368631
368607
 
368632
368608
  /**
@@ -368644,7 +368620,7 @@ function quoteArg$1(arg) {
368644
368620
  *
368645
368621
  * @returns {Function[]} A function pair to escape & quote arguments.
368646
368622
  */
368647
- function getQuoteFunction$3() {
368623
+ function getQuoteFunction$2() {
368648
368624
  return [escapeArgForQuoted$1, quoteArg$1];
368649
368625
  }
368650
368626
 
@@ -368655,82 +368631,12 @@ function getQuoteFunction$3() {
368655
368631
  * @param {string} arg The argument to update.
368656
368632
  * @returns {string} The updated argument.
368657
368633
  */
368658
- function stripFlagPrefix$2(arg) {
368659
- return arg.replace(/^(?:-+|\/+)/gu, "");
368660
- }
368661
-
368662
- /**
368663
- * Returns a function to protect against flag injection for CMD.
368664
- *
368665
- * @returns {Function} A function to protect against flag injection.
368666
- */
368667
- function getFlagProtectionFunction$3() {
368668
- return stripFlagPrefix$2;
368669
- }
368670
-
368671
- /**
368672
- * @overview Provides functionality for shell-less escaping on Windows systems.
368673
- * @license MPL-2.0
368674
- */
368675
-
368676
- /**
368677
- * The error message for use of quoting functionality.
368678
- *
368679
- * @constant
368680
- * @type {string}
368681
- */
368682
- const unsupportedError = "Quoting is not supported when no shell is used";
368683
-
368684
- /**
368685
- * Escape an argument for shell-less use.
368686
- *
368687
- * @param {string} arg The argument to escape.
368688
- * @returns {string} The escaped argument.
368689
- */
368690
- function escapeArg$1(arg) {
368691
- return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
368692
- }
368693
-
368694
- /**
368695
- * Returns a function to escape arguments for shell-less use.
368696
- *
368697
- * @returns {Function} A function to escape arguments.
368698
- */
368699
- function getEscapeFunction$2() {
368700
- return escapeArg$1;
368701
- }
368702
-
368703
- /**
368704
- * Returns the provided value.
368705
- *
368706
- * @throws {Error} Always.
368707
- */
368708
- function unsupported() {
368709
- throw new Error(unsupportedError);
368710
- }
368711
-
368712
- /**
368713
- * Returns a pair of functions that will indicate this operation is unsupported.
368714
- *
368715
- * @returns {Function[]} A pair of functions.
368716
- */
368717
- function getQuoteFunction$2() {
368718
- return [unsupported, unsupported];
368719
- }
368720
-
368721
- /**
368722
- * Remove any prefix from the provided argument that might be interpreted as a
368723
- * flag on Windows systems.
368724
- *
368725
- * @param {string} arg The argument to update.
368726
- * @returns {string} The updated argument.
368727
- */
368728
368634
  function stripFlagPrefix$1(arg) {
368729
368635
  return arg.replace(/^(?:-+|\/+)/gu, "");
368730
368636
  }
368731
368637
 
368732
368638
  /**
368733
- * Returns a function to protect against flag injection for Windows systems.
368639
+ * Returns a function to protect against flag injection for CMD.
368734
368640
  *
368735
368641
  * @returns {Function} A function to protect against flag injection.
368736
368642
  */
@@ -368744,12 +368650,12 @@ function getFlagProtectionFunction$2() {
368744
368650
  */
368745
368651
 
368746
368652
  /**
368747
- * Escape an argument for use in PowerShell.
368653
+ * Escape an argument for use in PowerShell when interpolation is active.
368748
368654
  *
368749
368655
  * @param {string} arg The argument to escape.
368750
368656
  * @returns {string} The escaped argument.
368751
368657
  */
368752
- function escapeArg(arg) {
368658
+ function escapeArgForInterpolation(arg) {
368753
368659
  arg = arg
368754
368660
  .replace(/[\0\u0008\r\u001B\u009B]/gu, "")
368755
368661
  .replace(/\n/gu, " ")
@@ -368771,14 +368677,31 @@ function escapeArg(arg) {
368771
368677
  return arg;
368772
368678
  }
368773
368679
 
368680
+ /**
368681
+ * Escape an argument for use in PowerShell when the argument is not being
368682
+ * quoted (but interpolation is inactive).
368683
+ *
368684
+ * @param {string} arg The argument to escape.
368685
+ * @returns {string} The escaped argument.
368686
+ */
368687
+ function escapeArgForNoInterpolation(arg) {
368688
+ return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
368689
+ }
368690
+
368774
368691
  /**
368775
368692
  * Returns a function to escape arguments for use in PowerShell for the given
368776
368693
  * use case.
368777
368694
  *
368695
+ * @param {object} options The options for escaping arguments.
368696
+ * @param {boolean} options.interpolation Is interpolation enabled.
368778
368697
  * @returns {Function} A function to escape arguments.
368779
368698
  */
368780
- function getEscapeFunction$1() {
368781
- return escapeArg;
368699
+ function getEscapeFunction$1(options) {
368700
+ if (options.interpolation) {
368701
+ return escapeArgForInterpolation;
368702
+ } else {
368703
+ return escapeArgForNoInterpolation;
368704
+ }
368782
368705
  }
368783
368706
 
368784
368707
  /**
@@ -368873,11 +368796,11 @@ const binPowerShell = "powershell.exe";
368873
368796
  * https://nodejs.org/api/child_process.html#default-windows-shell.
368874
368797
  *
368875
368798
  * @param {object} args The arguments for this function.
368876
- * @param {Object<string, string>} args.env The environment variables.
368799
+ * @param {object} args.env The environment variables.
368800
+ * @param {string} [args.env.ComSpec] The %COMSPEC% value.
368877
368801
  * @returns {string} The default shell.
368878
368802
  */
368879
- function getDefaultShell({ env }) {
368880
- const ComSpec = hasOwn(env, "ComSpec") ? env.ComSpec : undefined;
368803
+ function getDefaultShell({ env: { ComSpec } }) {
368881
368804
  if (ComSpec !== undefined) {
368882
368805
  return ComSpec;
368883
368806
  }
@@ -368888,19 +368811,17 @@ function getDefaultShell({ env }) {
368888
368811
  /**
368889
368812
  * Returns a function to escape arguments for use in a particular shell.
368890
368813
  *
368891
- * @param {string | symbol} shellName The name of a Windows shell.
368814
+ * @param {string} shellName The name of a Windows shell.
368815
+ * @param {object} options The options for escaping arguments.
368816
+ * @param {boolean} options.interpolation Is interpolation enabled.
368892
368817
  * @returns {Function | undefined} A function to escape arguments.
368893
368818
  */
368894
- function getEscapeFunction(shellName) {
368895
- if (shellName === noShell) {
368896
- return getEscapeFunction$2();
368897
- }
368898
-
368819
+ function getEscapeFunction(shellName, options) {
368899
368820
  switch (shellName.toLowerCase()) {
368900
368821
  case binCmd:
368901
- return getEscapeFunction$3();
368822
+ return getEscapeFunction$2(options);
368902
368823
  case binPowerShell:
368903
- return getEscapeFunction$1();
368824
+ return getEscapeFunction$1(options);
368904
368825
  }
368905
368826
  }
368906
368827
 
@@ -368908,17 +368829,13 @@ function getEscapeFunction(shellName) {
368908
368829
  * Returns a pair of functions to escape and quote arguments for use in a
368909
368830
  * particular shell.
368910
368831
  *
368911
- * @param {string | symbol} shellName The name of a Windows shell.
368832
+ * @param {string} shellName The name of a Windows shell.
368912
368833
  * @returns {Function[] | undefined} A function pair to escape & quote arguments.
368913
368834
  */
368914
368835
  function getQuoteFunction(shellName) {
368915
- if (shellName === noShell) {
368916
- return getQuoteFunction$2();
368917
- }
368918
-
368919
368836
  switch (shellName.toLowerCase()) {
368920
368837
  case binCmd:
368921
- return getQuoteFunction$3();
368838
+ return getQuoteFunction$2();
368922
368839
  case binPowerShell:
368923
368840
  return getQuoteFunction$1();
368924
368841
  }
@@ -368927,17 +368844,13 @@ function getQuoteFunction(shellName) {
368927
368844
  /**
368928
368845
  * Returns a function to protect against flag injection.
368929
368846
  *
368930
- * @param {string | symbol} shellName The name of a Windows shell.
368847
+ * @param {string} shellName The name of a Windows shell.
368931
368848
  * @returns {Function | undefined} A function to protect against flag injection.
368932
368849
  */
368933
368850
  function getFlagProtectionFunction(shellName) {
368934
- if (shellName === noShell) {
368935
- return getFlagProtectionFunction$2();
368936
- }
368937
-
368938
368851
  switch (shellName.toLowerCase()) {
368939
368852
  case binCmd:
368940
- return getFlagProtectionFunction$3();
368853
+ return getFlagProtectionFunction$2();
368941
368854
  case binPowerShell:
368942
368855
  return getFlagProtectionFunction$1();
368943
368856
  }
@@ -368947,7 +368860,7 @@ function getFlagProtectionFunction(shellName) {
368947
368860
  * Determines the name of the shell identified by a file path or file name.
368948
368861
  *
368949
368862
  * @param {object} args The arguments for this function.
368950
- * @param {Object<string, string>} args.env The environment variables.
368863
+ * @param {object} args.env The environment variables.
368951
368864
  * @param {string} args.shell The name or path of the shell.
368952
368865
  * @param {object} deps The dependencies for this function.
368953
368866
  * @param {Function} deps.resolveExecutable Resolve the path to an executable.
@@ -368960,17 +368873,11 @@ function getShellName({ env, shell }, { resolveExecutable }) {
368960
368873
  );
368961
368874
 
368962
368875
  const shellName = path__namespace.win32.basename(shell);
368963
- return shellName;
368964
- }
368876
+ if (getEscapeFunction(shellName, {}) === undefined) {
368877
+ return binCmd;
368878
+ }
368965
368879
 
368966
- /**
368967
- * Checks if the given shell is supported on Windows or not.
368968
- *
368969
- * @param {string} shellName The name of a Windows shell.
368970
- * @returns {boolean} `true` if the shell is supported, `false` otherwise.
368971
- */
368972
- function isShellSupported(shellName) {
368973
- return getEscapeFunction(shellName) !== undefined;
368880
+ return shellName;
368974
368881
  }
368975
368882
 
368976
368883
  var win = /*#__PURE__*/Object.freeze({
@@ -368979,8 +368886,7 @@ var win = /*#__PURE__*/Object.freeze({
368979
368886
  getEscapeFunction: getEscapeFunction,
368980
368887
  getFlagProtectionFunction: getFlagProtectionFunction,
368981
368888
  getQuoteFunction: getQuoteFunction,
368982
- getShellName: getShellName,
368983
- isShellSupported: isShellSupported
368889
+ getShellName: getShellName
368984
368890
  });
368985
368891
 
368986
368892
  /**
@@ -369023,8 +368929,7 @@ const win32 = "win32";
369023
368929
  * @returns {boolean} `true` if the system is Windows, `false` otherwise.
369024
368930
  */
369025
368931
  function isWindow({ env, platform }) {
369026
- const osType = hasOwn(env, "OSTYPE") ? env.OSTYPE : undefined;
369027
- return osType === cygwin || osType === msys || platform === win32;
368932
+ return env.OSTYPE === cygwin || env.OSTYPE === msys || platform === win32;
369028
368933
  }
369029
368934
 
369030
368935
  /**
@@ -369049,185 +368954,61 @@ function getHelpersByPlatform({ env, platform }) {
369049
368954
  *
369050
368955
  * @overview Entrypoint for the library.
369051
368956
  * @module shescape
369052
- * @version 2.1.0
368957
+ * @version 1.7.4
369053
368958
  * @license MPL-2.0
369054
368959
  */
369055
368960
 
369056
368961
 
369057
368962
  /**
369058
- * A class to escape user-controlled inputs to shell commands to prevent shell
369059
- * injection.
368963
+ * Get the helper functions for the current platform.
369060
368964
  *
369061
- * @example
369062
- * import { spawn } from "node:child_process";
369063
- * const shescape = new Shescape({ shell: false });
369064
- * spawn(
369065
- * "echo",
369066
- * ["Hello", shescape.escape(userInput)],
369067
- * null // `options.shell` MUST be falsy
369068
- * );
369069
- * @example
369070
- * import { spawn } from "node:child_process";
369071
- * const shescape = new Shescape({ shell: false });
369072
- * spawn(
369073
- * "echo",
369074
- * shescape.escapeAll(["Hello", userInput]),
369075
- * null // `options.shell` MUST be falsy
369076
- * );
369077
- * @example
369078
- * import { spawn } from "node:child_process";
369079
- * const spawnOptions = { shell: true }; // `options.shell` SHOULD be truthy
369080
- * const shescape = new Shescape({ shell: spawnOptions.shell });
369081
- * spawn(
369082
- * "echo",
369083
- * ["Hello", shescape.quote(userInput)],
369084
- * spawnOptions
369085
- * );
369086
- * @example
369087
- * import { spawn } from "node:child_process";
369088
- * const spawnOptions = { shell: true }; // `options.shell` SHOULD be truthy
369089
- * const shescape = new Shescape({ shell: spawnOptions.shell });
369090
- * spawn(
369091
- * "echo",
369092
- * shescape.quoteAll(["Hello", userInput]),
369093
- * spawnOptions
369094
- * );
368965
+ * @returns {object} The helper functions for the current platform.
369095
368966
  */
369096
- class Shescape {
369097
- /**
369098
- * Create a new {@link Shescape} instance.
369099
- *
369100
- * @param {object} [options] The escape options.
369101
- * @param {boolean} [options.flagProtection=true] Is flag protection enabled.
369102
- * @param {boolean | string} [options.shell=true] The shell to escape for.
369103
- * @throws {Error} The shell is not supported or could not be found.
369104
- * @since 2.0.0
369105
- */
369106
- constructor(options = {}) {
369107
- const platform = os.platform();
369108
- const helpers = getHelpersByPlatform({ env: process.env, platform });
369109
-
369110
- options = parseOptions({ env: process.env, options }, helpers);
369111
- const { flagProtection, shellName } = options;
369112
-
369113
- {
369114
- const escape = helpers.getEscapeFunction(shellName);
369115
- if (flagProtection) {
369116
- const flagProtect = helpers.getFlagProtectionFunction(shellName);
369117
- this._escape = (arg) => flagProtect(escape(arg));
369118
- } else {
369119
- this._escape = escape;
369120
- }
369121
- }
369122
-
369123
- {
369124
- const [escape, quote] = helpers.getQuoteFunction(shellName);
369125
- if (flagProtection) {
369126
- const flagProtect = helpers.getFlagProtectionFunction(shellName);
369127
- this._quote = (arg) => quote(flagProtect(escape(arg)));
369128
- } else {
369129
- this._quote = (arg) => quote(escape(arg));
369130
- }
369131
- }
369132
- }
369133
-
369134
- /**
369135
- * Take a single value, the argument, and escape any dangerous characters.
369136
- *
369137
- * Non-string inputs will be converted to strings using a `toString()` method.
369138
- *
369139
- * @param {string} arg The argument to escape.
369140
- * @returns {string} The escaped argument.
369141
- * @throws {TypeError} The argument is not stringable.
369142
- * @since 2.0.0
369143
- */
369144
- escape(arg) {
369145
- const argAsString = checkedToString(arg);
369146
- return this._escape(argAsString);
369147
- }
369148
-
369149
- /**
369150
- * Take an array of values, the arguments, and escape any dangerous characters
369151
- * in every argument.
369152
- *
369153
- * Non-string inputs will be converted to strings using a `toString()` method.
369154
- *
369155
- * @param {string[]} args The arguments to escape.
369156
- * @returns {string[]} The escaped arguments.
369157
- * @throws {TypeError} The arguments are not an array.
369158
- * @throws {TypeError} One of the arguments is not stringable.
369159
- * @since 2.0.0
369160
- */
369161
- escapeAll(args) {
369162
- return args.map((arg) => this.escape(arg));
369163
- }
369164
-
369165
- /**
369166
- * Take a single value, the argument, put shell-specific quotes around it and
369167
- * escape any dangerous characters.
369168
- *
369169
- * Non-string inputs will be converted to strings using a `toString()` method.
369170
- *
369171
- * @param {string} arg The argument to quote and escape.
369172
- * @returns {string} The quoted and escaped argument.
369173
- * @throws {TypeError} The argument is not stringable.
369174
- * @throws {Error} Quoting is not supported with `shell: false`.
369175
- * @since 2.0.0
369176
- */
369177
- quote(arg) {
369178
- const argAsString = checkedToString(arg);
369179
- return this._quote(argAsString);
369180
- }
369181
-
369182
- /**
369183
- * Take an array of values, the arguments, put shell-specific quotes around
369184
- * every argument and escape any dangerous characters in every argument.
369185
- *
369186
- * Non-string inputs will be converted to strings using a `toString()` method.
369187
- *
369188
- * @param {string[]} args The arguments to quote and escape.
369189
- * @returns {string[]} The quoted and escaped arguments.
369190
- * @throws {TypeError} The arguments are not an array.
369191
- * @throws {TypeError} One of the arguments is not stringable.
369192
- * @throws {Error} Quoting is not supported with `shell: false`.
369193
- * @since 2.0.0
369194
- */
369195
- quoteAll(args) {
369196
- return args.map((arg) => this.quote(arg));
369197
- }
368967
+ function getPlatformHelpers() {
368968
+ const platform = os.platform();
368969
+ const helpers = getHelpersByPlatform({ env: process.env, platform });
368970
+ return helpers;
369198
368971
  }
369199
368972
 
369200
- /**
369201
- * @overview Alternative entrypoint for the library that provides a stateless
369202
- * API.
369203
- * @license MPL-2.0
369204
- */
369205
-
369206
-
369207
368973
  /**
369208
368974
  * Take a single value, the argument, and escape any dangerous characters.
369209
368975
  *
369210
368976
  * Non-string inputs will be converted to strings using a `toString()` method.
369211
368977
  *
368978
+ * NOTE: when the `interpolation` option is set to `true`, whitespace is escaped
368979
+ * to prevent argument splitting except for cmd.exe (which does not support it).
368980
+ *
369212
368981
  * @example
369213
368982
  * import { spawn } from "node:child_process";
369214
368983
  * spawn(
369215
368984
  * "echo",
369216
- * ["Hello", shescape.escape(userInput, { shell: false })],
368985
+ * ["Hello", shescape.escape(userInput)],
369217
368986
  * null // `options.shell` MUST be falsy
369218
368987
  * );
369219
368988
  * @param {string} arg The argument to escape.
369220
368989
  * @param {object} [options] The escape options.
369221
- * @param {boolean} [options.flagProtection=true] Is flag protection enabled.
369222
- * @param {boolean | string} [options.shell=true] The shell to escape for.
368990
+ * @param {boolean} [options.flagProtection=false] Is flag protection enabled.
368991
+ * @param {boolean} [options.interpolation=false] Is interpolation enabled.
368992
+ * @param {boolean | string} [options.shell] The shell to escape for.
369223
368993
  * @returns {string} The escaped argument.
369224
368994
  * @throws {TypeError} The argument is not stringable.
369225
- * @throws {Error} The shell is not supported or could not be found.
369226
- * @since 2.1.0
368995
+ * @since 0.1.0
369227
368996
  */
369228
- function escape(arg, options) {
369229
- const shescape = new Shescape(options);
369230
- return shescape.escape(arg);
368997
+ function escape(arg, options = {}) {
368998
+ const helpers = getPlatformHelpers();
368999
+ const { flagProtection, interpolation, shellName } = parseOptions(
369000
+ { env: process.env, options },
369001
+ helpers,
369002
+ );
369003
+ const argAsString = checkedToString(arg);
369004
+ const escape = helpers.getEscapeFunction(shellName, { interpolation });
369005
+ const escapedArg = escape(argAsString);
369006
+ if (flagProtection) {
369007
+ const flagProtect = helpers.getFlagProtectionFunction(shellName);
369008
+ return flagProtect(escapedArg);
369009
+ } else {
369010
+ return escapedArg;
369011
+ }
369231
369012
  }
369232
369013
 
369233
369014
  /**
@@ -369241,21 +369022,21 @@ function escape(arg, options) {
369241
369022
  * import { spawn } from "node:child_process";
369242
369023
  * spawn(
369243
369024
  * "echo",
369244
- * shescape.escapeAll(["Hello", userInput], { shell: false }),
369025
+ * shescape.escapeAll(["Hello", userInput]),
369245
369026
  * null // `options.shell` MUST be falsy
369246
369027
  * );
369247
369028
  * @param {string[]} args The arguments to escape.
369248
369029
  * @param {object} [options] The escape options.
369249
- * @param {boolean} [options.flagProtection=true] Is flag protection enabled.
369250
- * @param {boolean | string} [options.shell=true] The shell to escape for.
369030
+ * @param {boolean} [options.flagProtection=false] Is flag protection enabled.
369031
+ * @param {boolean} [options.interpolation=false] Is interpolation enabled.
369032
+ * @param {boolean | string} [options.shell] The shell to escape for.
369251
369033
  * @returns {string[]} The escaped arguments.
369252
369034
  * @throws {TypeError} One of the arguments is not stringable.
369253
- * @throws {Error} The shell is not supported or could not be found.
369254
- * @since 2.1.0
369035
+ * @since 1.1.0
369255
369036
  */
369256
- function escapeAll(args, options) {
369257
- const shescape = new Shescape(options);
369258
- return shescape.escapeAll(args);
369037
+ function escapeAll(args, options = {}) {
369038
+ args = toArrayIfNecessary(args);
369039
+ return args.map((arg) => escape(arg, options));
369259
369040
  }
369260
369041
 
369261
369042
  /**
@@ -369267,54 +369048,72 @@ function escapeAll(args, options) {
369267
369048
  * @example
369268
369049
  * import { spawn } from "node:child_process";
369269
369050
  * const spawnOptions = { shell: true }; // `options.shell` SHOULD be truthy
369051
+ * const shescapeOptions = { shell: spawnOptions.shell };
369270
369052
  * spawn(
369271
369053
  * "echo",
369272
- * ["Hello", shescape.quote(userInput, { shell: spawnOptions.shell })],
369054
+ * ["Hello", shescape.quote(userInput, shescapeOptions)],
369273
369055
  * spawnOptions
369274
369056
  * );
369057
+ * @example
369058
+ * import { exec } from "node:child_process";
369059
+ * const execOptions = null || { };
369060
+ * const shescapeOptions = { shell: execOptions.shell };
369061
+ * exec(
369062
+ * `echo Hello ${shescape.quote(userInput, shescapeOptions)}`,
369063
+ * execOptions
369064
+ * );
369275
369065
  * @param {string} arg The argument to quote and escape.
369276
- * @param {object} [options] The escape options.
369277
- * @param {boolean} [options.flagProtection=true] Is flag protection enabled.
369278
- * @param {boolean | string} [options.shell=true] The shell to escape for.
369066
+ * @param {object} [options] The escape and quote options.
369067
+ * @param {boolean} [options.flagProtection=false] Is flag protection enabled.
369068
+ * @param {boolean | string} [options.shell] The shell to escape for.
369279
369069
  * @returns {string} The quoted and escaped argument.
369280
369070
  * @throws {TypeError} The argument is not stringable.
369281
- * @throws {Error} The shell is not supported or could not be found.
369282
- * @throws {Error} Quoting is not supported with `shell: false`.
369283
- * @since 2.1.0
369071
+ * @since 0.3.0
369284
369072
  */
369285
- function quote(arg, options) {
369286
- const shescape = new Shescape(options);
369287
- return shescape.quote(arg);
369073
+ function quote(arg, options = {}) {
369074
+ const helpers = getPlatformHelpers();
369075
+ const { flagProtection, shellName } = parseOptions(
369076
+ { env: process.env, options },
369077
+ helpers,
369078
+ );
369079
+ const argAsString = checkedToString(arg);
369080
+ const [escape, quote] = helpers.getQuoteFunction(shellName);
369081
+ const escapedArg = escape(argAsString);
369082
+ if (flagProtection) {
369083
+ const flagProtect = helpers.getFlagProtectionFunction(shellName);
369084
+ return quote(flagProtect(escapedArg));
369085
+ } else {
369086
+ return quote(escapedArg);
369087
+ }
369288
369088
  }
369289
369089
 
369290
369090
  /**
369291
369091
  * Take an array of values, the arguments, put shell-specific quotes around
369292
369092
  * every argument and escape any dangerous characters in every argument.
369293
369093
  *
369294
- * Non-array inputs will be converted to one-value arrays and non-string
369295
- * values will be converted to strings using a `toString()` method.
369094
+ * Non-array inputs will be converted to one-value arrays and non-string values
369095
+ * will be converted to strings using a `toString()` method.
369296
369096
  *
369297
369097
  * @example
369298
369098
  * import { spawn } from "node:child_process";
369299
369099
  * const spawnOptions = { shell: true }; // `options.shell` SHOULD be truthy
369100
+ * const shescapeOptions = { shell: spawnOptions.shell };
369300
369101
  * spawn(
369301
369102
  * "echo",
369302
- * shescape.quoteAll(["Hello", userInput], { shell: spawnOptions.shell }),
369103
+ * shescape.quoteAll(["Hello", userInput], shescapeOptions),
369303
369104
  * spawnOptions
369304
369105
  * );
369305
369106
  * @param {string[]} args The arguments to quote and escape.
369306
- * @param {object} [options] The escape options.
369307
- * @param {boolean} [options.flagProtection=true] Is flag protection enabled.
369308
- * @param {boolean | string} [options.shell=true] The shell to escape for.
369107
+ * @param {object} [options] The escape and quote options.
369108
+ * @param {boolean} [options.flagProtection=false] Is flag protection enabled.
369109
+ * @param {boolean | string} [options.shell] The shell to escape for.
369309
369110
  * @returns {string[]} The quoted and escaped arguments.
369310
369111
  * @throws {TypeError} One of the arguments is not stringable.
369311
- * @throws {Error} The shell is not supported or could not be found.
369312
- * @throws {Error} Quoting is not supported with `shell: false`.
369313
- * @since 2.1.0
369112
+ * @since 0.4.0
369314
369113
  */
369315
- function quoteAll(args, options) {
369316
- const shescape = new Shescape(options);
369317
- return shescape.quoteAll(args);
369114
+ function quoteAll(args, options = {}) {
369115
+ args = toArrayIfNecessary(args);
369116
+ return args.map((arg) => quote(arg, options));
369318
369117
  }
369319
369118
 
369320
369119
  exports.escape = escape;