From patchwork Fri Nov 19 04:36:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Art Nikpal X-Patchwork-Id: 1556893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=R8GjXqMr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwP6002vSz9s1l for ; Fri, 19 Nov 2021 15:37:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5145982FCD; Fri, 19 Nov 2021 05:37:10 +0100 (CET) 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="R8GjXqMr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9494D82FCF; Fri, 19 Nov 2021 05:37:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 5116280615 for ; Fri, 19 Nov 2021 05:37:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=email2tema@gmail.com Received: by mail-pl1-x62d.google.com with SMTP id z6so5986500plk.6 for ; Thu, 18 Nov 2021 20:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u2nWKxqTDNCDoddC5Kdvctrsoecpbbl2kNJTWreOBUg=; b=R8GjXqMrtjrZFzF7bJneHXaCKyN9hVVSTWwMKI+IwqVdD1N/q2Uz1BP4Um+htxwRgE ghWZBtTXVF2K9h4hBZX+Nc4dZ9Pfb/8kfhSPZwUWmWbPJkZKu+B3VcPIpjCvHxsFyoRP VXwKjDNozPH77sul6yysR01uK9ueJ1KZv6zSUg5qul0l/9S/rCFFIhEdpYnlIFhHmryQ BtII92DxsDDCxA/eXY4IkhsBXdlDxRHXHPsU7X+GPJgdBr0f+bvdiDUNIAZGIKm7NqMH EOFcTUkA5/LT3RTQT2gIVXyzIEPNKzHUI8G0k7ckMilDF3lntRu2/EhVM8cjPS4jdaVB X1hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u2nWKxqTDNCDoddC5Kdvctrsoecpbbl2kNJTWreOBUg=; b=vKR7dzuXtDPDucSNCR73D9s3ZtlKQlWzYVaO1p3rlLyx89YtZ7XYc3HDjc637CSFbA SB0dCjPGk/EXw9rT3aRdyCiUUQpE1OWg/5vPKCXOEkQiyk6AhJDRq0c86BmKjS6Ffc08 yP2NaBqDyP57hHvmhjvOmyxkxrgvx0/ZJBy7OD3ndJMfD77TuhJzuqIP4qMdEsLZ8WFV K9K+9V1SVdHhJ1YAcExaz/ZF9S7pmORnULSA/UU3/jT3EymExuvxBxvHvSPWDDvUG/q2 pcyTS2JcqcVt2lwbT1qF442mlWrbzyHxfAhIEIJKIFkdmKNnEeqvmmJGd9++beOE4ieL M7tA== X-Gm-Message-State: AOAM532/kLLFV2ivYue5Jfl8VWjmvlv+ONnwMFPEaRyRWK8PT/NVz+SW 6P6ZnEgqJHMqltLSLJ856k8= X-Google-Smtp-Source: ABdhPJzzrNv+nbM+K+gjWpMEPHmhrNXJCCORfyD0BTm8gRDYTudmyr7zooAYZTvGxeEThzffRM/kxA== X-Received: by 2002:a17:902:a5c5:b0:143:c3cf:739b with SMTP id t5-20020a170902a5c500b00143c3cf739bmr49159519plq.9.1637296623749; Thu, 18 Nov 2021 20:37:03 -0800 (PST) Received: from localhost.localdomain ([2409:8929:1a0b:9314:3a1e:44db:1de0:ce09]) by smtp.gmail.com with ESMTPSA id u23sm1113089pfl.185.2021.11.18.20.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 20:37:03 -0800 (PST) From: Artem Lapkin X-Google-Original-From: Artem Lapkin To: sjg@chromium.org Cc: trini@konsulko.com, marek.behun@nic.cz, narmstrong@baylibre.com, twarren@nvidia.com, andre.przywara@arm.com, u-boot@lists.denx.de, u-boot-amlogic@groups.io, christianshewitt@gmail.com, art@khadas.com, nick@khadas.com, gouwa@khadas.com Subject: [PATCH v2 0/2] env: setenv add resolve value option Date: Fri, 19 Nov 2021 12:36:45 +0800 Message-Id: <20211119043647.1251416-1-art@khadas.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 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 Add possibility setup env variable with additional resolving vars inside value. Usage examples: => setenv a hello; setenv b world; setenv c '${a} ${b}' => setenv -r d '${c}! ${a}...' => printenv d d=hello world! hello... /* internal usage example */ env_resolve("d", "${c}! ${a}..."); /* d="hello world! hello..." */ Artem Lapkin (2): env: setenv add resolve value option test: env: deep resolve value testing --- V2 changes: _ fix comments style _ add comment include/exports.h _ remake strcpy to strdup _ env_resolve minimize _ test added: test/py/tests/test_env.py: test_env_resovle --- cmd/nvedit.c | 43 ++++++++++++++++++++++++++++++++++++++- include/_exports.h | 1 + include/env.h | 11 ++++++++++ include/exports.h | 2 ++ test/py/tests/test_env.py | 24 ++++++++++++++++++++++ 5 files changed, 80 insertions(+), 1 deletion(-)