From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85153 invoked by alias); 31 May 2018 14:34:39 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 85136 invoked by uid 89); 31 May 2018 14:34:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot0-f178.google.com Received: from mail-ot0-f178.google.com (HELO mail-ot0-f178.google.com) (74.125.82.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 May 2018 14:34:36 +0000 Received: by mail-ot0-f178.google.com with SMTP id m11-v6so25511151otf.3 for ; Thu, 31 May 2018 07:34:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=e5taGM2YevOGuTZ+7gmbSaEYLt7OUWhkwMhgjgN5bRo=; b=GpGZNVCGYp/NC2QJud28Fdh3lvD6gUHQeUDLp+ScOy0vNofrCbd/jJOOp11b0N8t05 Jx6wK1i4ZuNu1acshc6xPl0rOzTWOzsrRjeJUVAxTql1WdA9PEzMX/Vhq4imasVnVb0E u5Y2NzlheJeJBAzRLhGW6bRV0dgMHi3z3zjSxf/xq5cH5tyqZtcd+wXI/mV8i/VAobRp 70UceGhk8OzH/MePS/aMqAYzWwY9DQJ01tqLykxoiauokBSn+96fNBS7mMVCAY3uSH22 WhTiJF9ATmaR3/D1abxBVZ2NHZdik6wktMOWseAnALQxPGalCqCyPmfRIckTsMPrL8sC JtnA== X-Gm-Message-State: APt69E30o2dKbKMOlIWeSVU1qhrCl3DLT/pfsNJxt76bVaNmoFKWqewA 1fEHidQBOvdVanUoftOTAYQpBGasfr09u7JO5lo= X-Google-Smtp-Source: ADUXVKLzrhd7BcYKZWgQzJgT9zQIvqXNvrGd40BqUHWIuWsHawMQNrje9WFhOapSbsbh46N44j44Gr9lw9JXt4AJI+0= X-Received: by 2002:a9d:2fda:: with SMTP id b26-v6mr4504954otd.177.1527777274894; Thu, 31 May 2018 07:34:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:40d2:0:0:0:0:0 with HTTP; Thu, 31 May 2018 07:34:34 -0700 (PDT) In-Reply-To: References: From: Keith Christian Date: Thu, 31 May 2018 21:53:00 -0000 Message-ID: Subject: Re: Help with C clearenv and setenv To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00337.txt.bz2 You're welcome, Sam. Keith On Wed, May 30, 2018 at 8:22 PM, Sam Habiel wrote: > Thank you Keith for you reply; but I am actually looking for the C APIs to > manipulate the environment; esp. to clear it. > > On Wed, May 30, 2018 at 6:05 PM, Keith Christian > wrote: > >> Sam, >> >> Here is a short demonstration of how to detect unset (possibly null, >> too?) variables in BASH. Not sure if this is exactly what you are >> looking for but presented for info. >> >> set -x;A_VAR="${RANDOM}";echo "1. ${A_VAR}";echo "2. >> ${A_VAR:?IS_NOT_SET}";unset A_VAR;set +x >> + set -x >> + A_VAR=28641 >> + echo '1. 28641' >> 1. 28641 >> + echo '2. 28641' >> 2. 28641 >> + unset A_VAR >> -bash: A_VAR: IS_NOT_SET >> >> >> Documentation for is in the BASH texinfo docs, read it in a Cygwin >> terminal by typing "info bash" and go to this section: >> >> >> 3.5.3 Shell Parameter Expansion >> ------------------------------- >> (( lines deleted )) (( lines deleted )) (( lines deleted )) >> '${PARAMETER:-WORD}' >> If PARAMETER is unset or null, the expansion of WORD is >> substituted. Otherwise, the value of PARAMETER is substituted. >> >> '${PARAMETER:=WORD}' >> If PARAMETER is unset or null, the expansion of WORD is assigned to >> PARAMETER. The value of PARAMETER is then substituted. Positional >> parameters and special parameters may not be assigned to in this >> way. >> >> '${PARAMETER:?WORD}' >> If PARAMETER is null or unset, the expansion of WORD (or a message >> to that effect if WORD is not present) is written to the standard >> error and the shell, if it is not interactive, exits. Otherwise, >> the value of PARAMETER is substituted. >> >> '${PARAMETER:+WORD}' >> If PARAMETER is null or unset, nothing is substituted, otherwise >> the expansion of WORD is substituted. >> (( lines deleted )) (( lines deleted )) (( lines deleted )) >> >> Keith >> >> On Wed, May 30, 2018 at 8:48 AM, Sam Habiel wrote: >> > I have code for a database I am porting to Cygwin. >> > >> > Part of that code is a clearenv() then a couple of setenvs. There is >> > an ifdef for Cygwin, as it doesn't implement clearenv. It just sets >> > environ = NULL. Well--that really breaks setenv! It returns a "Bad >> > Poniter" error (-1). >> > >> > What is the correct way to clear environment variables in Cygwin? >> > >> > --Sam >> > (About me: http://smh101.com/) >> > >> > -- >> > Problem reports: http://cygwin.com/problems.html >> > FAQ: http://cygwin.com/faq/ >> > Documentation: http://cygwin.com/docs.html >> > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >> > >> >> -- >> Problem reports: http://cygwin.com/problems.html >> FAQ: http://cygwin.com/faq/ >> Documentation: http://cygwin.com/docs.html >> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >> >> > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple