From patchwork Fri Sep 25 11:19:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1371175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=i1uBcq9+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ByTx721dVz9sSJ for ; Fri, 25 Sep 2020 21:20:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5653D82684; Fri, 25 Sep 2020 13:20:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="i1uBcq9+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EDFB3826B1; Fri, 25 Sep 2020 13:20:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0709.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::709]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D3DB2824A0 for ; Fri, 25 Sep 2020 13:20:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/O3IB2sBIDFhC1moICHZU4m8i35bl6Upm+Edn5a2JuMhx8IwJPz2qSxlELrBJPEjbJq4ia6/ITY6e6eZJOGRAl0SogIDMg0BxwiFITa9drDwGcdicqJUcm404mwleXxRVOG/TCDGYlNTkG8jf8PcwWpvvFQbpWX1zgvx0xQ5wOIh2MStZtJ4laZmbeWlS7F19NONxuq9320b5OwUYxDhVHD0Xshs9pDz3CR2hVGgBUE9zaddmGFdJPP8kLPNTcmon9W7A2t5KJij2og0nm0w3k1ljGzSZ2zD49hy/E9Oc//g6fhHb1QpYyKPDeUVMbnIY2dA9sA0ekfAqpaFkV/FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gwN6sTmsVIYGIvwyOiY0tbOrDmuT9mqHoLznXBZBBxY=; b=Z+3JdNIdYN+9ZHv8YAMU76qCJxiEUAAb0zZIMKZPSJS/rVH0NGeGL27BQvbntV3F5B0OYt13Dq3J8zC1+6b1ufLuIvpQ3cfvYwJxCG/qZJJjntMY7CGTB7T6P8Q6BaF1pWPG2KVWz1F/OU9ZQ4FaWyTV1bwVg2ELPBSno2Gaz9XyoSOymBXzTWA9jjJAstOG++JFZPeD8BYUeBfnqpWmRYW63mZd2KC03MeTf+EfR0L38buWAS6gA9aTG2RbpJc9v5+84kSCrVufmWSWm5LqhQIY2yonJtRU80CqhqBME+MeTBmZkYfKxzk6/FjxXzXiG5UC3PAmpIQ8RDLq5CEn7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gwN6sTmsVIYGIvwyOiY0tbOrDmuT9mqHoLznXBZBBxY=; b=i1uBcq9+xdxRjhhXNmW6aVnFr8JaSCbVy+LVQPVian8n6gea8khpPMGT52bVxATubTn9RnSFPjVIDiVvmMr/wZ2j1pjLikQJYte33MagJcggvsj4KJnBvgHufnCXx/0yXX59eVF9UIOB0ZTUZk528DfMA76J6yLXvflMw0lIc6g= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM4PR1001MB1252.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:200:90::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.15; Fri, 25 Sep 2020 11:20:33 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::acf4:4f51:6c3a:8cbc]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::acf4:4f51:6c3a:8cbc%5]) with mapi id 15.20.3412.020; Fri, 25 Sep 2020 11:20:33 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heinrich Schuchardt , Rasmus Villemoes Subject: [PATCH 0/3] add "call" command Date: Fri, 25 Sep 2020 13:19:39 +0200 Message-Id: <20200925111942.4629-1-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 X-ClientProxiedBy: AM6P193CA0065.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::42) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.115.188) by AM6P193CA0065.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22 via Frontend Transport; Fri, 25 Sep 2020 11:20:33 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.115.188] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84863821-0c1e-452f-6d1c-08d8614504af X-MS-TrafficTypeDiagnostic: AM4PR1001MB1252: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jb0FIQoSOTSAaKj2UP8IPgdVOrz8KMs1JBRb6wCExbJBzAbLXofh12Dqmev4wBXYur3IzGKJhqfO0mxMkE/XZu6ibLLAvXtFGjaY/xG83R1doPMF4k1qgLHcnWbJnOYqf2vtzB9tOr9/cFIY09o80VhexAP0ckFFwrp1JxSGSw/HXO/35WWspdglVxR3LmvG2I3xLnnUzvaWzMI2dPiOjpj6U/wMRmUzXMDB2fxT93cXOu+SLExKN25nEsDt2D5mnhKpLqd5OUJqBS85XDKacgiQVKpgIvglWftk7f3Asml1l8Go9Ixw90Nm9vqnYOYmfSzTe9nOh5iOel7PJ38ayqohVkPloAbHoe2237eATtV9Ee314wyLK7eJxYZ8kSv8 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(396003)(39830400003)(136003)(366004)(346002)(376002)(83380400001)(26005)(66556008)(66946007)(36756003)(8676002)(6512007)(107886003)(2616005)(66476007)(8936002)(6486002)(8976002)(4326008)(16526019)(6506007)(54906003)(5660300002)(2906002)(6916009)(86362001)(44832011)(1076003)(478600001)(52116002)(186003)(316002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: rOyQKXjMkPZDMo9gPoiCLYJ3Ft5u9FJTpOwI10K1Yr/0HPHaekhleCOxU+xJ+v0cElqMIyvSbgPWHG4btVY7a+nIHDWnAxI6mr3fSvlzXbrlvhOQNTjQm41Syi7TUF5VeMgUh1zFifU2YCwmKopsTfukSf04HFAz7t+ixFwhQCbDlu7IFyDe2trxW9XX9STCVS5SvaAJmftkniHfcD9v65HxZduGsb/zhfcgY/YEVZIqwE9PpHTm37tAzKyL70Mpn/hu3OoUDAvm1XZ4c5Ovo4z1sK5gp4K7SgnTKIevp+CvzqVht28BXmphKchlViBEXePRjnFNvM0WKjPnlW4qSUc+QqUhmzaaidvbS3dX+OvnvXCAx2ae0csU6LqNSRdBqJ7vc5CKCxUHoDc+23fQaiX7+BGQ2CPZ5cl2tAwlO6tXxECHa2UMcK+Hr7CwAbfWqz3vpdiwBlCFxr23pcEY0Y4Vg8WPgUAVrBTtydPHGMGF4W6Fuaj5yNi+BUOc5UIDACtl7FND0FdQnvckL7GArr5YhbyQGwSvfEVS4ce72y/MuKEL/RWyz1JTW/+iRKrg6R0Oh+h9qJj61m1HibneG+9PWTbkQmWYEEIZaN7QFgCoj6iA3qXcdt9016L00fiFN5nZFEeFimjw2wWNspgD9Q== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 84863821-0c1e-452f-6d1c-08d8614504af X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:20:33.4097 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZtKtvdvAOpiRjUBOk6EVnyt+PK6JgtLBq6z+Z40b0KbiRQkxtqQkEgvH2dTudKtWfb5gcyK20UDTuem35/r+GBiGN5r+KeV7ntwv99gBg48= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR1001MB1252 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This adds a way to call a "function" defined in the environment with arguments. I.e., whereas run foo requires one to set the (shell or environment) variables referenced from foo beforehand, with this one can instead do call foo arg1 arg2 arg3 and use $1... up to $9 in the definition of foo. $# is set so foo can make decisions based on that, and ${3:-default} works as expected. As I write in patch 2, it should be possible to get rid of the "call" and simply allow foo arg1 arg2 arg3 i.e. if the search for a command named foo fails, try an environment variable by that name and do it as "call". But that change of behaviour, I think, requires a separate opt-in config knob, and can be done later if someone actually wants that. Rasmus Villemoes (3): cli_hush.c: refactor handle_dollar() to prepare for cmd_call cli_hush.c: add "call" command ut: add small hush tests cmd/Kconfig | 8 ++++ common/cli_hush.c | 93 +++++++++++++++++++++++++++++++++---- configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + include/test/suites.h | 1 + test/cmd/Makefile | 1 + test/cmd/hush.c | 90 +++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 6 +++ 8 files changed, 191 insertions(+), 10 deletions(-) create mode 100644 test/cmd/hush.c