Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Aug 2018 15:02:53 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338407 - head/stand/common
Message-ID:  <201808311502.w7VF2rjM050697@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Fri Aug 31 15:02:53 2018
New Revision: 338407
URL: https://svnweb.freebsd.org/changeset/base/338407

Log:
  lualoader: Print error messages from command failures at the prompt
  
  Previously lualoader would remain silent, rather than printing
  command_errmsg or noting that a command had failed or was not found.
  
  Approved by:	re (gjb)

Modified:
  head/stand/common/interp_lua.c

Modified: head/stand/common/interp_lua.c
==============================================================================
--- head/stand/common/interp_lua.c	Fri Aug 31 08:37:15 2018	(r338406)
+++ head/stand/common/interp_lua.c	Fri Aug 31 15:02:53 2018	(r338407)
@@ -135,7 +135,7 @@ interp_run(const char *line)
 	char	**argv;
 	lua_State *luap;
 	struct interp_lua_softc	*softc = &lua_softc;
-	int status;
+	int status, ret;
 
 	luap = softc->luap;
 	LDBG("executing line...");
@@ -147,14 +147,16 @@ interp_run(const char *line)
 		 * run it through cli_execute. If that fails, then we'll try it
 		 * as a builtin.
 		 */
+		command_errmsg = NULL;
 		if (parse(&argc, &argv, line) == 0) {
 			lua_getglobal(luap, "cli_execute");
 			for (nargc = 0; nargc < argc; ++nargc) {
 				lua_pushstring(luap, argv[nargc]);
 			}
 			status = lua_pcall(luap, argc, 1, 0);
+			ret = lua_tointeger(luap, 1);
 			lua_pop(luap, 1);
-			if (status != 0) {
+			if (status != 0 || ret != 0) {
 				/*
 				 * Lua cli_execute will pass the function back
 				 * through loader.command, which is a proxy to
@@ -166,7 +168,10 @@ interp_run(const char *line)
 				status = interp_builtin_cmd(argc, argv);
 			}
 			if (status != 0) {
-				printf("Command failed\n");
+				if (command_errmsg != NULL)
+					printf("%s\n", command_errmsg);
+				else
+					printf("Command failed\n");
 				status = CMD_ERROR;
 			}
 			free(argv);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808311502.w7VF2rjM050697>