Skip to content

Commit 2d09c1d

Browse files
authored
Merge pull request #93 from Univers42/develop
chore(release): 2.8.2 -> main
2 parents a0138b5 + 299f6fa commit 2d09c1d

24 files changed

Lines changed: 670 additions & 12 deletions

‎RELEASE.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,32 @@ shows you how to drive the shell.
88

99
---
1010

11+
## v2.8.2 — *the customize-your-prompt release*
12+
13+
Paste any zsh prompt tutorial into `~/.hellishrc` and it now just works
14+
(issue #91):
15+
16+
- **`colors`** defines `$fg[..]`, `$bg[..]`, `$fg_bold[..]`,
17+
`$reset_color` — the arrays zsh's own colors function provides.
18+
- **`vcs_info`** fills `$vcs_info_msg_0_` from the prompt's fork-free
19+
cached git reader; **`zstyle`** silently honours the
20+
`formats`/`actionformats` it reads (everything else keeps the loud stub).
21+
- **`precmd` / `preexec`** functions (and the `precmd_functions` /
22+
`preexec_functions` arrays) fire like zsh's — unless bash-preexec is
23+
loaded, which owns the convention and would otherwise double-fire.
24+
- **`RPROMPT`** renders at the right margin, invisible to readline's
25+
width model, skipped on dumb terminals.
26+
- And the bug that started it: the alias scanner expanded aliases inside
27+
`case` **patterns**, so re-sourcing a config whose loader contains
28+
`case "$1" in list|ls)` died on
29+
`syntax error near unexpected token --color=auto` with the stock
30+
`ls` alias active. Patterns are never commands now — 12 golden cases
31+
diff every shape (`|`, `(`, `;;`, `;&`, `;;&`, newline-led, nested)
32+
against bash 5.3.9, and `tests/prompt_zshrc_test.py` drives the whole
33+
tutorial rc on a pty inside a real repository, ten checks.
34+
35+
---
36+
1137
## v2.8.1 — *the first-prompt release*
1238

1339
A fresh `curl install.sh | sh` with the plugin framework, bash-preexec and z

‎incs/ft_builtins.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ int builtin_emulate(t_shell *state, t_vec argv);
130130
int builtin_print(t_shell *state, t_vec argv);
131131
int builtin_autoload(t_shell *state, t_vec argv);
132132
int builtin_zunsupported(t_shell *state, t_vec argv);
133+
int builtin_colors(t_shell *state, t_vec argv);
134+
int builtin_vcs_info(t_shell *state, t_vec argv);
135+
int builtin_zstyle(t_shell *state, t_vec argv);
133136
int builtin_zle(t_shell *state, t_vec argv);
134137
int builtin_bindkey(t_shell *state, t_vec argv);
135138
int builtin_add_zsh_hook(t_shell *state, t_vec argv);

‎incs/helpers.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ void rc_load_all(t_shell *state, const char *home);
6969

7070
/* Composable rc hooks (src/core/hooks*.c). */
7171
void run_hook_funcs(t_shell *state, char *var, const char *arg);
72+
void hook_run_one(t_shell *state, const char *fn, const char *arg);
73+
void run_zsh_prompt_hooks(t_shell *state, const char *which,
74+
const char *arg);
7275
void run_preexec(t_shell *state);
7376

7477
#endif

‎incs/prompt.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ typedef struct s_shell t_shell;
2929
`prompt` switcher bring it back. */
3030
# define HELLISH_PS1_DEFAULT "%m\\U%# "
3131

32+
/* The prompt's fork-free cached git reader (prompt_metadata.c): branch is
33+
heap-owned by the caller, dirty is the TTL-throttled `git status`
34+
answer. Public because vcs_info (builtin_zsh_prompt.c) reports the
35+
same repository state the \g escape renders. */
36+
void get_git_info(char **branch, int *dirty);
37+
3238
// buff_readline.c
3339
typedef struct s_rl
3440
{

‎incs/sh_alias.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ typedef struct s_ascan_src
5555
bool blank_end;
5656
} t_ascan_src;
5757

58+
/* Where the scan stands inside `case … esac` (cs_st, with cs_n the
59+
nesting depth): the SUBJECT word, the `in` that follows it, the PATTERN
60+
region (where `|`, `(`, newlines and `;;` must NOT re-arm command
61+
position -- bash never alias-expands a pattern, issue #91), or the
62+
command BODY after a `)`. */
63+
# define CS_NONE 0
64+
# define CS_SUBJ 1
65+
# define CS_IN 2
66+
# define CS_PAT 3
67+
# define CS_BODY 4
68+
5869
typedef struct s_ascan
5970
{
6071
t_ascan_src src[ALIAS_SCAN_DEPTH];
@@ -65,6 +76,9 @@ typedef struct s_ascan
6576
bool chk_next;
6677
bool wstart;
6778
bool after_redir;
79+
bool was_cmd;
80+
int cs_n;
81+
int cs_st;
6882
int pend_hd;
6983
char *hd_delim[ALIAS_HD_MAX];
7084
bool hd_strip[ALIAS_HD_MAX];
@@ -88,6 +102,8 @@ bool asc_active(t_ascan *a, const char *w, size_t len);
88102
void asc_word(t_ascan *a);
89103
void asc_op(t_ascan *a);
90104
void asc_newline(t_ascan *a);
105+
bool asc_case_word(t_ascan *a, const char *w, size_t len, bool plain);
106+
bool asc_op_case(t_ascan *a, t_ascan_src *s);
91107
void asc_comment(t_ascan *a);
92108
void asc_hd_delim(t_ascan *a, const char *w, size_t len);
93109
void asc_hd_drop(t_ascan *a);

‎incs/version.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/* The single source of truth for the running shell's version. Bumped in step
1717
with the git tag / GitHub release / npm package / docker image. */
18-
# define HELLISH_VERSION "2.8.1"
18+
# define HELLISH_VERSION "2.8.2"
1919

2020
/* Where releases live; used by the `update` builtin and the daily check. */
2121
# define HELLISH_REPO "Univers42/hellish"

‎npm/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hellish-shell",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "hellish — a fast, POSIX-compliant shell, with horns",
55
"bin": {
66
"hellish": "bin/hellish.js"

‎src/alias/alias_scan2.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ static void asc_word_state(t_ascan *a, const char *w, size_t len, bool plain)
7171
{
7272
if (a->after_redir)
7373
a->after_redir = false;
74+
else if (asc_case_word(a, w, len, plain))
75+
;
7476
else if (plain && asc_kw_cmdnext(w, len))
7577
a->cmd_pos = true;
7678
else if (plain && asc_kw_noncmd(w, len))
@@ -117,6 +119,7 @@ void asc_word(t_ascan *a)
117119

118120
s = &a->src[a->depth - 1];
119121
len = asc_word_span(s->s + s->pos, &plain);
122+
a->was_cmd = (a->cmd_pos || a->chk_next);
120123
if (asc_word_verbatim(a, s, len))
121124
return ;
122125
if (!a->after_redir && (a->cmd_pos || a->chk_next) && plain

‎src/alias/alias_scan3.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void asc_op(t_ascan *a)
3838
char c;
3939

4040
s = &a->src[a->depth - 1];
41+
if (asc_op_case(a, s))
42+
return ;
4143
c = s->s[s->pos];
4244
vec_push(&a->out, &c);
4345
s->pos++;

‎src/alias/alias_scan6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void asc_newline(t_ascan *a)
6262
vec_push(&a->out, &c);
6363
while (a->hd_n > 0 && s->s[s->pos])
6464
asc_hd_body(a, s);
65-
a->cmd_pos = true;
65+
a->cmd_pos = (a->cs_n == 0 || a->cs_st == CS_BODY);
6666
a->chk_next = false;
6767
a->after_redir = false;
6868
a->pend_hd = 0;

0 commit comments

Comments
 (0)