On Sat, Nov 29, 2025 at 4:30 PM Dimitar Dimitrov <[email protected]> wrote:
>
> Hello,
> In `expand.c::expand_string_buf` there is a `switch (*p)` and in its
> default case, there is
> ```
> if (ISSPACE (p[-1]))
>     break;
> ```
> It seems to me that, at that point in the code, `p[-1]` is always `$`

You are right.
Maybe this check was needed in a prior revision.

diff --git a/src/expand.c b/src/expand.c
index d14feba7..647b1fe8 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -554,8 +554,7 @@ expand_string_buf (char *buf, const char *string,
size_t length)
           break;

         default:
-          if (ISSPACE (p[-1]))
-            break;
+          assert (p[-1] == '$');

           /* A $ followed by a random char is a variable reference:
              $a is equivalent to $(a).  */

regards, Dmitry

Reply via email to