delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/05/30/22:22:27

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=DoerFvk
nbu6b0E1K3Xi8KRE4DvkaXMUlExwAkoZUtZBuC7S46wb2C5w7bPe6egNHZpvlPOZ
3vtezcnZZ30e1ywdMjEvj39SYZY9ksdmGajU+DYq9aLbZIPcG/ZLG+eRkhzBS1c0
V9sHisQfJdsPT3tSXJW2EjSHNBFNj/NJY+Ho=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; s=default; bh=0qbvgPZgONCv7
2hjm2F3fsVVJ/s=; b=qS1cF5iA8winN4v39bGaB6WwuK9F9vb8n0cbN+jF5YL88
r01eYUusvHY3RKV9r6tcc9MWW87kEYFoNUaDQFIQUrnoz+LjuOVBGgaeCcvStCLi
slVt4LefOAOKt5K/5ehorWXLoOdHEicWb39jCRZHw5+6CDsQLXwwprA58CVNPo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:v13-v6s, HX-Received:sk:v3-v6mr, H*c:alternative, Shell
X-HELO: mail-wr0-f170.google.com
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=PUycWS4UtpTraGCRUeBosPVIALgeyeN5yRh7rYbf8ho=; b=LiB3rkS5sR1Sc8RD4yZtwnUSCTeA4n3QhZ55g0p7An7EFbe/3Rde2UNXElXOLxzkar lthASgniohg5VXBMRx/YMTa4B0mieFa3r9+J4essSvo2CoFR+xdjV7TA6YZya/D7x4vw Xti8ni2nAfxeQH1kW+0DU31ACAUNb6TEnT0rCSdEqbYj1rLpjX4hZ7/El3wza7fVPJa4 OBsK7+e4o5WWg4+56IEs67TPSxDAvQApdEP5tg7/fcRIy4yTIVKUzjqiYpR9W+XsdVRk dy0Hyvp3xOfmXFw8vWpTnJsBnNr2D6A53op3OEIwASff7KAq8O4A86ywiEINJD+oLaee qQ+Q==
X-Gm-Message-State: ALKqPwcmHjHiKY2OlfgkhzAUNMf+L09iOo/tSK+TFmH/bAIdEX03CoxH 8i5JxeDTdLNml08HvZgqBdQAnutDOBG4y/tzu3j++w==
X-Google-Smtp-Source: ADUXVKIVMd3r6iGMU+kEl+VuFqcKmVhD0OpZuvVnIG7Sv4U1GTLMYBSEEggHXlj5UpNyXCaMhLbecwD5dThvfeCqSQU=
X-Received: by 2002:adf:ebc3:: with SMTP id v3-v6mr3736749wrn.33.1527733330735; Wed, 30 May 2018 19:22:10 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <CAFWoy7FnGEJjEz+rTr=VNrmk3hqaJ0pQH7yB+iuJK25dwMrvdg@mail.gmail.com>
References: <CABHT962nB5jK2sNP9jGaVEbWGrvD72hBVN_q6xX9TKuq3yQ0Gg AT mail DOT gmail DOT com> <CAFWoy7FnGEJjEz+rTr=VNrmk3hqaJ0pQH7yB+iuJK25dwMrvdg AT mail DOT gmail DOT com>
From: Sam Habiel <sam DOT habiel AT gmail DOT com>
Date: Wed, 30 May 2018 22:22:10 -0400
Message-ID: <CABHT9632LBGQZmRQjyifmd2vWLu24XCP8oJEaMYWu8qHsvpP+A@mail.gmail.com>
Subject: Re: Help with C clearenv and setenv
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

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 <keith1christian AT gmail DOT com>
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 <sam DOT habiel AT gmail DOT com> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019