X-Recipient: archive-cygwin@delorie.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=Xdb3d0Q
	gczWO4IzBeftamgTULJd533Zk7cHcVoMSMAFx/q7vuRm1nsuUXyTtXMNbnapMu8t
	g1kJUHD6sTz9uUDHimiUSeKVYGId5djkIzgxq96/jfYMH+V1mJVj1fbKHSejEO33
	+kQ8FSyu4A8oSU5bwYnr7bdaeTs9Yt+B4RJQ=
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=42RIu99gM4zLc
	BuA4vVi09qW8tQ=; b=h91zVlgOgQP4VhAeJVHepr/ScjNVi6AKtyZB+v5YB7DKT
	xJqFFUVvi5P9yIuNLjSG83tQunZ587Xjgb+hFMvfrWzoKWY7XQXQK8yTpFTdCQyX
	g5DJFjBk1R8zmILVFz73M1VSxPq600trTpc3g/rBuR+6nU7zVKVyS+S3Idr1/8=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-6.3 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=Shell, Habiel, habiel
X-HELO: mail-ot0-f174.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=EtAoCYNzX3wckBQRo4mVGpKgdIPGzWUktg9DVMbM380=;        b=fqSXBZJXZV+7ZHePPCE70FBiu4E6NApgb5WQFm9vkzzaIq8uzpuygSpYhtElkAMz8I         JrVkb2Xf1cez2cU6pCqfiEp261NlG2TrF1S9KE0+Hh4FjJbEwXoAIuSvMnlC3Tgdctb3         G+T3+DZeSWmdfTa6wSc+J7WmHmenflnwPjQ68dzKpr6Mn19Pvcl0/rvNh/51+KaQhnBT         7W7R90MY47V9orFvBr/VMtihhNxnqg9NjWjEyXgunAamsGbWy8cwJfGvvnu5dAlIvA6e         /PcZmWqFOb6m9hqjv+Kk5p2uA4iZeygwbyi9eaCPNwV7yir5IrXTfaOVGwHNuro5wk2b         XLFw==
X-Gm-Message-State: ALKqPweuHLGqAwa54ccO3Fbn9IKP8gj24hxBOpnUkvg5az8Qyclm1o/j	C4g7g4hdeG/lo+cjrG/HjOaF2oGr6xcwX999U4w67A==
X-Google-Smtp-Source: ADUXVKLZNL7idiiFctfCK+DaK8TcAV+bWT52QgwlMoVPDLnOPoJ7HXRqHNOFGsGpep1Ah8v2pyR7y7qvbYrtqAoTNxQ=
X-Received: by 2002:a9d:5b32:: with SMTP id x47-v6mr3193099oth.26.1527717948006; Wed, 30 May 2018 15:05:48 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <CABHT962nB5jK2sNP9jGaVEbWGrvD72hBVN_q6xX9TKuq3yQ0Gg@mail.gmail.com>
References: <CABHT962nB5jK2sNP9jGaVEbWGrvD72hBVN_q6xX9TKuq3yQ0Gg@mail.gmail.com>
From: Keith Christian <keith1christian@gmail.com>
Date: Wed, 30 May 2018 16:05:47 -0600
Message-ID: <CAFWoy7FnGEJjEz+rTr=VNrmk3hqaJ0pQH7yB+iuJK25dwMrvdg@mail.gmail.com>
Subject: Re: Help with C clearenv and setenv
To: cygwin@cygwin.com
Content-Type: text/plain; charset="UTF-8"
X-IsSubscribed: yes

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.habiel@gmail.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

