This patch enhances the Unix shell simulation mode to support the UNIX
exit command.
On VMS, exit 1 is success and exit 0 is a failure.
With GNV$MAKE_UNIX_SIM enabled, exit 1 is now a failure and exit 0 is a
success.
Regards,
-John
>From 55638f37333c9b539312698d163df8de37d37421 Mon Sep 17 00:00:00 2001
From: John Malmberg <wb8...@qsl.net>
Date: Tue, 6 Jan 2015 22:01:59 -0600
Subject: [PATCH] vms_shell_sim_exit
* vmsjobs.c(build_vms_cmd): Improve Unix shell similation to simulate
an exit command in a shell. This allows more Unix makefiles to just
work on VMS.
---
README.VMS | 2 +-
vmsjobs.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/README.VMS b/README.VMS
index 71110ee..4a56fd1 100644
--- a/README.VMS
+++ b/README.VMS
@@ -63,7 +63,7 @@ Recipe differences:
* Single quotes are converted to double quotes and any double
quotes inside of them are doubled. No environment variable expansion
is simulated.
- * FUTURE: A exit command status will be converted to a Posix Exit
+ * A exit command status will be converted to a Posix Exit
where 0 is success and non-zero is failure.
* Untested: The $ character will cause environment variable expansion.
diff --git a/vmsjobs.c b/vmsjobs.c
index 3789098..1385a57 100644
--- a/vmsjobs.c
+++ b/vmsjobs.c
@@ -596,7 +596,9 @@ build_vms_cmd (char **cmd_tokens,
cmd_dsc->dsc$w_length = 0;
return cmd_dsc;
}
- cmd = xmalloc (MAX_DCL_CMD_LINE_LENGTH + 1);
+
+ /* Max DCL command + 1 extra token and trailing space */
+ cmd = xmalloc (MAX_DCL_CMD_LINE_LENGTH + 256);
cmd[0] = '$';
cmd[1] = 0;
@@ -643,6 +645,71 @@ build_vms_cmd (char **cmd_tokens,
return cmd_dsc;
}
}
+ else if (strncmp (cmd_tokens[cmd_tkn_index], "exit", 5) == 0)
+ {
+ /* Copy the exit command */
+ strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
+ cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
+ free (cmd_tokens[cmd_tkn_index++]);
+ if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
+ {
+ errno = E2BIG;
+ break;
+ }
+
+ /* Optional whitespace */
+ if (isspace (cmd_tokens[cmd_tkn_index][0]))
+ {
+ strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
+ cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
+ free (cmd_tokens[cmd_tkn_index++]);
+ if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
+ {
+ errno = E2BIG;
+ break;
+ }
+ }
+
+ /* There should be a status, but it is optional */
+ if (cmd_tokens[cmd_tkn_index][0] == ';')
+ continue;
+
+ /* If Unix simulation, add '((' */
+ if (vms_unix_simulation)
+ {
+ strcpy (&cmd[cmd_len], "((");
+ cmd_len += 2;
+ if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
+ {
+ errno = E2BIG;
+ break;
+ }
+ }
+
+ /* Add the parameter */
+ strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
+ cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
+ free (cmd_tokens[cmd_tkn_index++]);
+ if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
+ {
+ errno = E2BIG;
+ break;
+ }
+
+ /* Add " * 8) .and. %x7f8) .or. %x1035a002" */
+ if (vms_unix_simulation)
+ {
+ const char *end_str = " * 8) .and. %x7f8) .or. %x1035a002";
+ strcpy (&cmd[cmd_len], end_str);
+ cmd_len += strlen (end_str);
+ if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
+ {
+ errno = E2BIG;
+ break;
+ }
+ }
+ continue;
+ }
/* auto pipe needs spaces before semicolon */
if (use_pipe_cmd == add_pipe)
--
1.7.9
_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make