All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: "Steve Bennett" <steveb@workware.net.au>,
	"Wolfgang Denk" <wd@denx.de>,
	"Rasmus Villemoes" <rasmus.villemoes@prevas.dk>,
	"U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Tom Rini" <trini@konsulko.com>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Roland Gaudig" <roland.gaudig-oss@weidmueller.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Kostas Michalopoulos" <badsector@runtimeterror.com>
Subject: Re: [RFC PATCH 03/28] cli: lil: Replace strclone with strdup
Date: Mon, 5 Jul 2021 11:42:52 -0400	[thread overview]
Message-ID: <d7dc2037-a27e-c0c3-5f8e-043ba6c55fe3@gmail.com> (raw)
In-Reply-To: <CAPnjgZ0Ca3s3Z_Zm-FxfeLQhMh26DjJ6byd5Ygnfk9r+8c1D_w@mail.gmail.com>

On 7/5/21 11:29 AM, Simon Glass wrote:
> Hi,
> 
> On Mon, 5 Jul 2021 at 08:42, Sean Anderson <seanga2@gmail.com> wrote:
>>
>> On 7/5/21 1:07 AM, Steve Bennett wrote:
>>> On 4 Jul 2021, at 5:26 am, Wolfgang Denk <wd@denx.de> wrote:
>>>>
>>>> Dear Sean,
>>>>
>>>> In message <d3a91238-db2f-edbe-ecec-ddb5dc848ed7@gmail.com> 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.
> 
> I think these are good points, particularly the thing about
> mutiltasking. In fact I think it would be better if hush could
> implement things like '| grep xxx' since it would be useful in U-Boot.
> 
> But in any case, adding lil does not preclude someone coming along and
> adaptive hush for U-Boot (and this time upstreaming the changes!). I
> have seen discussions about updating hush for several years and no one
> has done it. I took a quick look and found it was about 3x the size it
> used to be and was not even sure where to start in terms of adapting
> it for single-threaded use.
> 
> Re this patch, I think it should be sent upstream.

I believe it will not be accepted, since strdup is POSIX and not C99.

--Sean

  reply	other threads:[~2021-07-05 15:43 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01  6:15 [RFC PATCH 00/28] cli: Add a new shell Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 01/28] Add Zlib License Sean Anderson
2021-07-05 15:29   ` Simon Glass
2021-07-01  6:15 ` [RFC PATCH 02/28] cli: Add LIL shell Sean Anderson
2021-07-02 11:03   ` Wolfgang Denk
2021-07-02 13:33     ` Sean Anderson
2021-07-03  2:12       ` Sean Anderson
2021-07-03 19:33         ` Wolfgang Denk
2021-07-05 15:29           ` Simon Glass
2021-07-05 19:10           ` Tom Rini
2021-07-05 19:47             ` Sean Anderson
2021-07-05 19:53               ` Tom Rini
2021-07-05 19:55                 ` Sean Anderson
2021-07-06  7:46               ` Wolfgang Denk
2021-07-06  7:52                 ` Michael Nazzareno Trimarchi
2021-07-06 14:57                   ` Simon Glass
2021-07-06 15:48                     ` Tom Rini
2021-07-07  8:22                     ` Michael Nazzareno Trimarchi
2021-07-06 14:54                 ` Tom Rini
2021-07-07  8:15                   ` Wolfgang Denk
2021-07-07 13:58                     ` Tom Rini
2021-07-07 14:10                       ` Wolfgang Denk
2021-07-07 14:14                         ` Tom Rini
2021-07-07 14:23                           ` Wolfgang Denk
2021-07-06  7:44             ` Wolfgang Denk
2021-07-06 15:43               ` Tom Rini
2021-07-06 16:09                 ` Kostas Michalopoulos
2021-07-07 13:32                   ` Sean Anderson
2021-07-07  8:15                 ` Wolfgang Denk
2021-07-07 13:46                   ` Sean Anderson
2021-07-07 13:51                     ` Tom Rini
2021-07-07 13:58                   ` Tom Rini
2021-07-07 14:48                   ` Marek Behun
2021-07-08  5:19                     ` Michael Nazzareno Trimarchi
2021-07-08 15:33                       ` Tom Rini
2021-07-08  4:56               ` Sean Anderson
2021-07-08 17:00                 ` Wolfgang Denk
2021-07-03 19:23       ` Wolfgang Denk
2021-07-01  6:15 ` [RFC PATCH 03/28] cli: lil: Replace strclone with strdup Sean Anderson
2021-07-02  8:36   ` Rasmus Villemoes
2021-07-02 11:38     ` Wolfgang Denk
2021-07-02 13:38     ` Sean Anderson
2021-07-02 14:28       ` Tom Rini
2021-07-02 22:18       ` Kostas Michalopoulos
2021-07-03  2:28         ` Sean Anderson
2021-07-03 19:26       ` Wolfgang Denk
2021-07-05  5:07         ` Steve Bennett
2021-07-05 14:42           ` Sean Anderson
2021-07-05 15:29             ` Simon Glass
2021-07-05 15:42               ` Sean Anderson [this message]
2021-07-05 17:50             ` Wolfgang Denk
2021-07-08  4:37               ` Sean Anderson
2021-07-08 16:13                 ` Wolfgang Denk
2021-07-01  6:15 ` [RFC PATCH 04/28] cli: lil: Remove most functions by default Sean Anderson
2021-07-05 15:29   ` Simon Glass
2021-07-01  6:15 ` [RFC PATCH 05/28] cli: lil: Rename some functions to be more like TCL Sean Anderson
2021-07-05 15:29   ` Simon Glass
2021-07-05 15:54     ` Sean Anderson
2021-07-05 17:58       ` Wolfgang Denk
2021-07-05 18:51         ` Tom Rini
2021-07-05 21:02           ` Simon Glass
2021-07-05 21:36             ` Tom Rini
2021-07-06  7:52           ` Wolfgang Denk
2021-07-06 15:21             ` Simon Glass
2021-07-06 15:33             ` Tom Rini
2021-07-06 16:00               ` Kostas Michalopoulos
2021-07-07  8:16               ` Wolfgang Denk
2021-07-07 13:58                 ` Tom Rini
2021-07-05 19:46         ` Sean Anderson
2021-07-06  7:50           ` Wolfgang Denk
2021-07-08  4:47             ` Sean Anderson
2021-07-08 16:21               ` Wolfgang Denk
2021-07-01  6:15 ` [RFC PATCH 06/28] cli: lil: Convert some defines to enums Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 07/28] cli: lil: Simplify callbacks Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 08/28] cli: lil: Handle commands with dots Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 09/28] cli: lil: Use error codes Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 10/28] cli: lil: Add printf-style format helper for errors Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 11/28] cli: lil: Add several helper functions " Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 12/28] cli: lil: Check for ctrl-c Sean Anderson
2021-07-05 15:29   ` Simon Glass
2021-07-01  6:15 ` [RFC PATCH 13/28] cli: lil: Wire up LIL to the rest of U-Boot Sean Anderson
2021-07-02  8:18   ` Rasmus Villemoes
2021-07-02 13:40     ` Sean Anderson
2021-07-05 15:29   ` Simon Glass
2021-07-01  6:15 ` [RFC PATCH 14/28] cli: lil: Document structures Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 15/28] cli: lil: Convert LIL_ENABLE_POOLS to Kconfig Sean Anderson
2021-07-01  6:15 ` [RFC PATCH 16/28] cli: lil: Convert LIL_ENABLE_RECLIMIT to KConfig Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 17/28] test: Add tests for LIL Sean Anderson
2021-07-05 15:29   ` Simon Glass
2021-07-01  6:16 ` [RFC PATCH 18/28] cli: lil: Remove duplicate function bodies Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 19/28] cli: lil: Add "symbol" structure Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 20/28] cli: lil: Add config to enable debug output Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 21/28] cli: lil: Add a distinct parsing step Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 22/28] env: Add a priv pointer to hwalk_r Sean Anderson
2021-07-01 20:10   ` Tom Rini
2021-07-01  6:16 ` [RFC PATCH 23/28] cli: lil: Handle OOM for hm_put Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 24/28] cli: lil: Make proc always take 3 arguments Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 25/28] cli: lil: Always quote items in lil_list_to_value Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 26/28] cli: lil: Allocate len even when str is NULL in alloc_value_len Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 27/28] cli: lil: Add a function to quote values Sean Anderson
2021-07-01  6:16 ` [RFC PATCH 28/28] cli: lil: Load procs from the environment Sean Anderson
2021-07-01 20:21 ` [RFC PATCH 00/28] cli: Add a new shell Tom Rini
2021-07-02 11:30   ` Wolfgang Denk
2021-07-02 13:56     ` Sean Anderson
2021-07-02 14:07   ` Sean Anderson
2021-07-08  3:49 ` Heiko Schocher
2021-07-08  4:26   ` Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7dc2037-a27e-c0c3-5f8e-043ba6c55fe3@gmail.com \
    --to=seanga2@gmail.com \
    --cc=badsector@runtimeterror.com \
    --cc=marek.behun@nic.cz \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=roland.gaudig-oss@weidmueller.com \
    --cc=sjg@chromium.org \
    --cc=steveb@workware.net.au \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wd@denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.