From nobody Tue Jan 24 22:12:20 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1h6D4Srkz3bfgq; Tue, 24 Jan 2023 22:12:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1h6D2zZPz3CL4; Tue, 24 Jan 2023 22:12:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2JbO5bfzQtaZXZMejan9Y9H3Sf0eelurV2ErXTrUtI0=; b=nCXfGFoBAxeR1vTTpdLTRlXD/LO24iV0ijuTtCk/4DS7TMaymSUMbt6TldrSUyl8r9WOrC 3jdo6Ws96lO7pNk6b0rdKelnk/nYje5To+HcruItXoXXWY/qgNPSWD/br7a7aAheknjMI/ whumZOuEfq1hD8ZVjwyGyw9596xoSQNqXUMsyEmnL1UpJwlp4h8T3Ms27e5/KInUFgji0a 9tnsxCpZeZo2orT2o9R9a0TZam3bYnjOX2X2dXoJW65UdDSuvvimnYi5OokMPgnieBlkkz rtokuOqiVvZ137jffAKCfUokq54E+hI4Kzg02oo7et8WndzZ4qqXoNNL1uDw5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2JbO5bfzQtaZXZMejan9Y9H3Sf0eelurV2ErXTrUtI0=; b=cUj2Qld8DdDy4jKli/dxbqteD2woYWajHZ5M6tSerHz1smOaQfd56her7yEk0EKkHGmNlD gfyLI0vvt1NXiQKHJWMSqQ6a4ZEDgmcBstLh1UXrby5pdMN/QeoiF6OmR2Q47fzGznajVK kxAOB/q6OoG6jkW7yPryYJJWO79BsalRtIQcA0yP65F89PRPSyXbpLnyu1r9yDQR3x6Vez 8kFwRw/uikvMMlbrB+0q8C40ZSrAaj/Y0DiqIHSrlW006MFuBK7q/Pz2ujbY6ZdcOYGfSb 4Bik959ddmXeJTx03L4rE4IiqIbgO4YtaOCzcF7plPnwaAUX+aC6kDF1TnSOQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598340; a=rsa-sha256; cv=none; b=YVle3t+KIzzBH5TfdRYiEW0Yaig7QxZs/EoQtsPkOYx2m5gUCyf0ewQrjTOqGY1/gFbjx4 F+Zw7QnxZNgW2x8mWKK8ZhDcHwb5eQU9yWqussLKX89InLCkIQhrXRG8DepEN9THX1fkp2 QQCA9T69uUcC/mUbcHK99jZZfyLg+AwD3NdbJxllJ9dQbClIfZdxk0foKu7QiPse+gPiEU rPE7eWV9BXuFk34pxYtLD0Z+fAd6jm9ECYa/b+q9NWvZHfaGTJyplHj6voGkQ7VVQdgCrg aCdfNk6c+Dnjuac/B4JbQBFvGYqVWCTef1GeIovXYh01UUeimll4RjUlDvwWEQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P1h6D1GpbzQXx; Tue, 24 Jan 2023 22:12:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30OMCKOZ086884; Tue, 24 Jan 2023 22:12:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMCK34086883; Tue, 24 Jan 2023 22:12:20 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:12:20 GMT Message-Id: <202301242212.30OMCK34086883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 69c6f6347c12 - stable/13 - stand: Add lua binding loader.has_command List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 69c6f6347c126df97245499a18d94537de5cdefd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=69c6f6347c126df97245499a18d94537de5cdefd commit 69c6f6347c126df97245499a18d94537de5cdefd Author: Warner Losh AuthorDate: 2022-09-01 17:06:19 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:32 +0000 stand: Add lua binding loader.has_command Give scripts the ability to determine if the currently running loader has provided a command. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36365 (cherry picked from commit 29fc4075e69fd27de0cded313ac6000165d99f8b) --- stand/liblua/lutils.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/stand/liblua/lutils.c b/stand/liblua/lutils.c index 9243edd07e8f..1649ac9fd508 100644 --- a/stand/liblua/lutils.c +++ b/stand/liblua/lutils.c @@ -63,6 +63,21 @@ lua_command(lua_State *L) return 1; } +static int +lua_has_command(lua_State *L) +{ + const char *cmd; + + if (lua_gettop(L) != 1) { + lua_pushnil(L); + return 1; + } + cmd = luaL_checkstring(L, 1); + lua_pushinteger(L, interp_has_builtin_cmd(cmd)); + + return 1; +} + static int lua_perform(lua_State *L) { @@ -539,9 +554,9 @@ static const struct luaL_Reg loaderlib[] = { REG_SIMPLE(interpret), REG_SIMPLE(parse), REG_SIMPLE(getenv), + REG_SIMPLE(has_command), REG_SIMPLE(perform), - /* Also registered as the global 'printc' */ - REG_SIMPLE(printc), + REG_SIMPLE(printc), /* Also registered as the global 'printc' */ REG_SIMPLE(setenv), REG_SIMPLE(time), REG_SIMPLE(unsetenv),