From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 404F5C07E99 for ; Mon, 5 Jul 2021 14:42:13 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 692526195E for ; Mon, 5 Jul 2021 14:42:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 692526195E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ED0E082A29; Mon, 5 Jul 2021 16:42:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iu2qNBQs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5655882B66; Mon, 5 Jul 2021 16:42:08 +0200 (CEST) Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F141482A29 for ; Mon, 5 Jul 2021 16:42:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x831.google.com with SMTP id x24so2551082qts.11 for ; Mon, 05 Jul 2021 07:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=N6Ot6N0v3GzDcbuN3/6639Wo/FsQZ9ybDZ844B8itdE=; b=iu2qNBQsjZ12nUNg0qvvi0QHZM5R0gMP2eQZOE+O89QKoOSDz9hDE101vKaYDDsQe3 dRwh+8T9hZXP5Dfh8y6r0E6SkHBSpfCKvMQT11muvCwt8kae++Gy8qrjGZ9acMmnlR6O lKcH23Snc91qTDvNT1zbl+xenqgKbideJ70fnuW19CHeLqdimBNEyAMKGlC1WiFaBc/5 DroNFFMhepqB0A7lJVNE+4O/MsTD6kmcCJY42OzvcMoA8MkQkZ12cKzR+gDJ6xK300ZK tulMbEgeMU5r7pLXFBsjVex1xarJSSzKgaY5lJLzYYfNt4plcSNawTUgQtPORUg13dxj YETg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=N6Ot6N0v3GzDcbuN3/6639Wo/FsQZ9ybDZ844B8itdE=; b=Rl1G6uiD7oKlD8nDMqKuOV48SFwqfjmONEhJol/QPxFR+YvTA7zxi/2uoff0nqWR5m 0yzV2XqucuuqKtOpDo+iXaqTI0VLyzSCVeVkLHOh8R2ysdJNKpiFGmrTVS4iXNXmMBgv V1BW6yuOQpiSQIfI4R8ha6IpAnozO5v6AyTFSenSxPxR4Kz8LbRQ+Jzh7jW7NPnor4fJ DFVggk60JdU7GnlfMjx6O19zaL7b+N3c/91JYNv1h/lJcFQOxOtibfL1jpQFRXdAtmMM EvNTuDS034dl3zf2KTE1EbV+9FCQ+1UN/8E33ngMHG3NKDnrvA3vuFLDPUPI5Qtvsaqf cyQw== X-Gm-Message-State: AOAM533b3k+Hh+0M2UQjvRB9lOypgdki12Ijc00gFdShe65wrmkoBHgx 6IDHrDxu5EeixO1x60isUW4= X-Google-Smtp-Source: ABdhPJzFLqGZRcst4k6U9kGvx+OlG0STaLgyP33VSjsGfM9jK7O8KHmEFmSMH/5u7NH6PhJxCBAAIA== X-Received: by 2002:a05:622a:50f:: with SMTP id l15mr13180692qtx.263.1625496123529; Mon, 05 Jul 2021 07:42:03 -0700 (PDT) Received: from [192.168.1.201] (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.googlemail.com with ESMTPSA id x5sm5450610qke.92.2021.07.05.07.42.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jul 2021 07:42:03 -0700 (PDT) From: Sean Anderson Subject: Re: [RFC PATCH 03/28] cli: lil: Replace strclone with strdup To: Steve Bennett , Wolfgang Denk Cc: Rasmus Villemoes , u-boot@lists.denx.de, Tom Rini , =?UTF-8?Q?Marek_Beh=c3=ban?= , Simon Glass , Roland Gaudig , Heinrich Schuchardt , Kostas Michalopoulos References: <20210701061611.957918-1-seanga2@gmail.com> <20210701061611.957918-4-seanga2@gmail.com> <17176.1625340369@gemini.denx.de> <54A6EFA6-8D5B-4779-B344-87BCC8C14B9C@workware.net.au> Message-ID: <5a967151-94f0-6037-2d02-0114c43b846c@gmail.com> Date: Mon, 5 Jul 2021 10:42:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <54A6EFA6-8D5B-4779-B344-87BCC8C14B9C@workware.net.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean On 7/5/21 1:07 AM, Steve Bennett wrote: > On 4 Jul 2021, at 5:26 am, Wolfgang Denk wrote: >> >> Dear Sean, >> >> In message you wrote: >>> >>> Well, since Hush was never updated, I don't believe LIL will be either. >> >> Let's please be exact here: Hus has never been updated _in_U-Boot_, >> but it has seen a lot of changes upstream, which apparently fix all >> the issues that motivated you to look for a replacement. >> >>> I think reducing the amount of ifdefs makes the code substantially >>> easier to maintain. My intention is to just use LIL as a starting point >>> which can be modified as needed to better suit U-Boot. >>> >>> The other half of this is that LIL is not particularly actively >>> developed. I believe the author sees his work as essentially >>> feature-complete, so I expect no major features which we might like to >>> backport. >> >> This sounds like an advantage, indeed, but then you can also >> interpret this as betting on a dead horse... > > My 2c on this. > > I am the maintainer of JimTcl (and I agree it is too big to be considered a candidate). > LIL source code has almost zero comments, poor error checking and no test suite. FWIW I added a (small) test suite in "[RFC PATCH 17/28] test: Add tests for LIL" based on the tests included in the LIL distibution. However, I really would like to expand upon it. > I would be very hesitant to adopt it in u-boot without serious work. I think around half of the "serious work" has already been done. I have worked on most of the core of LIL, and added error handling and comments. I believe that most of the remaining instances of dropping errors lie in the built-in commands. > I would much rather see effort put into updating hush to upstream. AIUI hush has diverged significantly from what U-Boot has. This would not be an "update" moreso than a complete port in the style of the current series. > My guess is that Denys would be amenable to small changes to make it easier to synchronise > with busybox in the future. I don't think sh-style shells are a good match for U-Boot's execution environment in the first place. The fundamental idea of an sh-style shell is that the output of one command can be redirected to the input (or arguments) of another command. This cannot be done (or rather would be difficult to do) in U-Boot for a few reasons * U-Boot does not support multithreading. Existing shells tend to depend strongly on this feature of the enviromnent. Many of the changes to U-Boot's hush are solely to deal with the lack of this feature. * Existing commands do not read from stdin, nor do they print useful information to stdout. Command output is designed for human consumption and is substantially more verbose than typical unix commands. * Tools such as grep, cut, tr, sed, sort, uniq, etc. which are extremely useful when working with streams are not present in U-Boot. And of course, this feature is currently not present in U-Boot. To get around this, commands resort to two of my least-favorite hacks: passing in the name of a environmental variable and overloading the return value. For an example of the first, consider => part uuid mmc 0:1 my_uuid which will set my_uuid to the uuid of the selected partition. My issue with this is threefold: every command must add new syntax to do this, that syntax is inconsistent, and it prevents easy composition. Consider a script which wants to iterate over partitions. Instead of doing for p in $(part list mmc 0); do # ... done it must instead do part list mmc 0 partitions for p in $partitions; do # ... done which unnecessarily adds an extra step. This overhead accumulates with each command which adds something like this. The other way to return more information is to use the return value. Consider the button command; it currently returns 0 ON, the button is pressed 1 OFF, the button is released 0 button list was shown 1 button not found 1 invalid arguments and so there is no way to distinguish between whether the button is off, whether the button does not exist, or whether there was a problem with the button driver. Both of these workarounds are natural consequences of using a sh-tyle shell in an environment it is not suited for. If we are going to go to the effort of porting a new language (which must be done no matter if we use Hush or some other language), we should pick one which has better support for single-threaded programming. --Sean