Skip to content

Commit

Permalink
mamake: %{VAR|script}/%{VAR@script}: expand MAM vars (re: f58153d)
Browse files Browse the repository at this point in the history
A minor omission: %{...} was not expanded in the one-line scriptlet
before passing it to the shell. While the Mamfiles don't currently
use or require this, it's only logical to do so.

src/cmd/INIT/mamake.c: substitute(): case '|':
- When adding the script code to the buffer, use a recursive
  substitute() call instead of an append() call.
  • Loading branch information
McDutchie committed Sep 4, 2024
1 parent fc90cc9 commit 7170ac0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* coded for portability
*/

#define RELEASE_DATE "2024-08-24"
#define RELEASE_DATE "2024-09-94"
static char id[] = "\n@(#)$Id: mamake (ksh 93u+m) " RELEASE_DATE " $\0\n";

#if _PACKAGE_ast
Expand Down Expand Up @@ -892,7 +892,7 @@ static void substitute(Buf_t *buf, char *s)
int valid_sh_name; /* if set, the variable name is valid in sh(1) */
int newexp; /* if set, %{...}, otherwise ${...} */
char *vnterm; /* pointer to byte following variable name */
char **argv; /* argument list for %{var^arbitrary sh(1) commands} */
char **argv; /* argument list for %{variable@sh script} */

while (c = *s++)
{
Expand Down Expand Up @@ -1069,7 +1069,7 @@ static void substitute(Buf_t *buf, char *s)
add(scr, '<'), append(scr, in);
add(scr, '>'), append(scr, out), add(scr, '\n');
n = *s, *s = 0; /* change final '}' to string terminator */
append(scr, t);
substitute(scr, t);
q = use(scr);
if ((argv ? (argv[2] = q, execute_v(NULL, argv)) : execute(NULL, q)) != 0)
error_out("expansion script error", t);
Expand Down

0 comments on commit 7170ac0

Please sign in to comment.