Skip to content

Commit ea9ea74

Browse files
authored
fix: Correctly parse operands from the command arguments (#401)
1 parent 025d5a4 commit ea9ea74

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1717
* fix(lisp): Report error only inside the command's execution ([#389](../../pull/389))
1818
* fix: Correct entry file name to `eask.js` instead of `eask` ([#397](../../pull/397))
1919
* fix: Ensure that `eask.js` has Unix line-endings ([#398](../../pull/398))
20+
* fix: Correctly parse operands from the command arguments ([#401](../../pull/401))
2021

2122
## 0.12.x
2223
> Released Dec 02, 2025

cmds/core/emacs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports.handler = async (argv) => {
3232
let s_path = UTIL.el_script('core/emacs');
3333

3434
let default_cmd = [EASK_EMACS, '-Q', '-l', s_path];
35-
let rest = process.argv.slice(3);
35+
let rest = UTIL.take_after(process.argv, EASK_EMACS);
3636
let cmd = default_cmd.concat(rest);
3737

3838
UTIL.setup_env();

cmds/core/exec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exports.builder = async (yargs) => {
3030
};
3131

3232
exports.handler = async (argv) => {
33-
let cmd = process.argv.slice(3);
33+
let cmd = UTIL.take_after(process.argv, 'exec');
3434

3535
await UTIL.e_call(argv, 'core/exec', '--', cmd);
3636

src/util.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ function escape_str(str) {
5050
return str.replaceAll('\"', '\\"');
5151
}
5252

53+
/**
54+
* Return arguments after matching string.
55+
*/
56+
function take_after(arr, str) {
57+
let index = arr.indexOf(str);
58+
if (index === -1)
59+
return arr;
60+
return arr.slice(index + 1);
61+
}
62+
5363
/**
5464
* Return arguments after `--` in list.
5565
*/
@@ -300,6 +310,7 @@ module.exports.which = which;
300310
module.exports.slash = slash;
301311

302312
module.exports.escape_str = escape_str;
313+
module.exports.take_after = take_after;
303314
module.exports.cli_args = cli_args;
304315
module.exports.plugin_dir = plugin_dir;
305316
module.exports.def_flag = def_flag;

0 commit comments

Comments
 (0)