From nobody Mon Feb 9 23:42:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579194963; cv=none; d=zohomail.com; s=zohoarc; b=huidYQyTlSErcbXaIapBMAP6s5+Lml4Crl83MyLxzTmhgH1nGKOCV0sqkb3d5PeTpjJ+Xa7N+LUqdJddu3RAfaL1992U/mYjXIMhQ3CUNpFKq4P8yHd4BIhXBCA+gqgzt3/t8F3WmHmHnN948Alkglgs+SoObLW1kgpxnPAShjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579194963; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I4G/46GcgzPWcj1xzGhH/tG3/vM5CWrEwCqw/hlXEtk=; b=DGFcqFA67qBRxaalqomRUTrjLBe4elH5eS4c/WUEwDhf2sMzSv4T/RGN3XPtHWu8bXibvvGTiDfVudjrfXQlIN4E562m3b+8GCUUq6EEVfVHNxkW8VX/j9Pv4JoiDg63REHh0IreHsChMAd4PDsMQPF/Spy6ufv1gBwBb1bgA7s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15791949630861022.2477594103367; Thu, 16 Jan 2020 09:16:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-x5GZ_bq5OEiwC1H5KotaBA-1; Thu, 16 Jan 2020 12:15:58 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7628B477; Thu, 16 Jan 2020 17:15:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 188ED100E7E3; Thu, 16 Jan 2020 17:15:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CEF9F845EC; Thu, 16 Jan 2020 17:15:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00GHFno1004323 for ; Thu, 16 Jan 2020 12:15:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 893697C41A; Thu, 16 Jan 2020 17:15:49 +0000 (UTC) Received: from foo.home.annexia.org (ovpn-117-237.ams2.redhat.com [10.36.117.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9E95842BA; Thu, 16 Jan 2020 17:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579194961; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=I4G/46GcgzPWcj1xzGhH/tG3/vM5CWrEwCqw/hlXEtk=; b=WRMywKlpDluPcxbU+v7mqDZs5xzbmw2HzaxqaDuhJT9Myec0KOOrgb0Rwr6QFCbSqc4+hc 0QwnlyUohDJAREluY8V98u81mFCRAnAUElLzsnfbWpHD8ZjEwgS8TIK9IV22tz8iFUJKNu WZDiKX9VS13Z5ySYMtCoUX/Ei6z/UAo= From: "Richard W.M. Jones" To: libvir-list@redhat.com Subject: [PATCH 1/2] run.in: Add intelligent prepend function. Date: Thu, 16 Jan 2020 17:15:41 +0000 Message-Id: <20200116171542.2764144-2-rjones@redhat.com> In-Reply-To: <20200116171542.2764144-1-rjones@redhat.com> References: <20200116171542.2764144-1-rjones@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: x5GZ_bq5OEiwC1H5KotaBA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This has been used in libguestfs and libnbd for quite a while as it makes the ./run script easier to read and write. See also: http://stackoverflow.com/a/9631350 Signed-off-by: Richard W.M. Jones Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Erik Skultety --- run.in | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/run.in b/run.in index 8574f81463..3118f9a9a4 100644 --- a/run.in +++ b/run.in @@ -42,22 +42,20 @@ # #---------------------------------------------------------------------- =20 +# Function to intelligently prepend a path to an environment variable. +# See http://stackoverflow.com/a/9631350 +prepend() +{ + eval $1=3D"$2\${$1:+:\$$1}" +} + # Find this script. b=3D@abs_builddir@ =20 -library_path=3D"$b/src/.libs" -if [ -z "$LD_LIBRARY_PATH" ]; then - LD_LIBRARY_PATH=3D$library_path -else - LD_LIBRARY_PATH=3D"$library_path:$LD_LIBRARY_PATH" -fi +prepend LD_LIBRARY_PATH "$b/src/.libs" export LD_LIBRARY_PATH =20 -if [ -z "$PKG_CONFIG_PATH" ]; then - PKG_CONFIG_PATH=3D"$b/src" -else - PKG_CONFIG_PATH=3D"$b/src:$PKG_CONFIG_PATH" -fi +prepend PKG_CONFIG_PATH "$b/src" export PKG_CONFIG_PATH =20 # Ensure that any 3rd party apps using libvirt.so from the build tree get --=20 2.24.1