Skip to content

Commit 2302fc5

Browse files
leifericfclaude
andcommitted
Treat ( [ { # @ ' positional arg as inline expression
The standalone binary now evaluates a positional argument that begins with a Lisp form character instead of treating it as a file path. Matches the convenience shape other Lisp CLIs offer for one-shot evaluation: mino "(+ 1 2)" -- 3 mino "[1 2 3]" -- [1 2 3] mino "(println :hi)" -- :hi / nil Trigger characters: ( [ { # @ '. Anything else is still treated as a file path. The -- separator forces file-or-task interpretation; -e EXPR works as before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 07107dc commit 2302fc5

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## v0.74.3 — One-Shot Expression CLI
4+
5+
The standalone `mino` binary now treats a positional argument
6+
that begins with a Lisp form character as an inline expression,
7+
matching the convenience shape other Lisp CLIs offer:
8+
9+
```
10+
mino "(+ 1 2)" # 3
11+
mino "[1 2 3]" # [1 2 3]
12+
mino "{:a 1}" # {:a 1}
13+
mino "(println :hi)" # :hi / nil
14+
```
15+
16+
Form characters that trigger expression mode: `(`, `[`, `{`,
17+
`#`, `@`, `'`. A leading `--` separator forces file-or-task
18+
interpretation; the explicit `-e EXPR` flag still works either
19+
way; everything else continues to be treated as a file path.
20+
File names that happen to start with one of those characters
21+
need an explicit `--` or path prefix (e.g. `mino ./(name).clj`),
22+
but that's a vanishingly rare case in practice.
23+
24+
`--help` documents the new shape on its own line under USAGE.
25+
326
## v0.74.2 — Heap-Allocated Dynamic Binding Frames
427

528
Fixes the v0.74.1 known-issue Windows SIGSEGV during

main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static void print_usage(FILE *out)
295295
"\n"
296296
"USAGE:\n"
297297
" mino [OPTIONS] [FILE]\n"
298+
" mino [OPTIONS] EXPR # EXPR starts with ( [ { # @ '\n"
298299
" mino [OPTIONS] -e EXPR\n"
299300
" mino <SUBCOMMAND> [ARGS...]\n"
300301
"\n"
@@ -676,6 +677,23 @@ int main(int argc, char **argv)
676677
first = argc;
677678
}
678679

680+
/* When the first positional argument starts with a character that
681+
* unambiguously begins a Lisp form, evaluate it as an expression
682+
* instead of treating it as a file path. Matches the convenience
683+
* shape other Lisp CLIs offer for `mino "(+ 1 2)"`. The `--`
684+
* separator forces file-or-task interpretation; the explicit
685+
* `-e EXPR` flag still works either way. */
686+
if (!dash_dash && first < argc) {
687+
char c = argv[first][0];
688+
if (c == '(' || c == '[' || c == '{'
689+
|| c == '#' || c == '@' || c == '\'') {
690+
exit_code = run_eval_expr(S, env, argv[first]);
691+
mino_env_free(S, env);
692+
mino_state_free(S);
693+
return exit_code;
694+
}
695+
}
696+
679697
/* File mode: evaluate a script and exit. */
680698
if (first < argc) {
681699
mino_val_t *result = mino_load_file(S, argv[first], env);

src/mino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
#define MINO_VERSION_MAJOR 0
2929
#define MINO_VERSION_MINOR 74
30-
#define MINO_VERSION_PATCH 2
30+
#define MINO_VERSION_PATCH 3
3131

3232
/*
3333
* Human-readable version string of the *linked* runtime, e.g. "0.48.0".

0 commit comments

Comments
 (0)