public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Sam Habiel <sam.habiel@gmail.com>
To: cygwin@cygwin.com
Subject: Re: Help with C clearenv and setenv
Date: Thu, 31 May 2018 08:58:00 -0000	[thread overview]
Message-ID: <CABHT9632LBGQZmRQjyifmd2vWLu24XCP8oJEaMYWu8qHsvpP+A@mail.gmail.com> (raw)
In-Reply-To: <CAFWoy7FnGEJjEz+rTr=VNrmk3hqaJ0pQH7yB+iuJK25dwMrvdg@mail.gmail.com>

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

--
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

  reply	other threads:[~2018-05-31  2:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 16:55 Sam Habiel
2018-05-31  3:56 ` Keith Christian
2018-05-31  8:58   ` Sam Habiel [this message]
2018-05-31 21:53     ` Keith Christian
2018-05-31  9:38 ` Marco Atzeri
2018-05-31 13:22   ` Eliot Moss
2018-05-31 17:57 ` Eric Blake
2018-06-04 19:39   ` Ken Brown
2018-06-04 20:22     ` Sam Habiel
2018-06-06 13:02       ` Sam Habiel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABHT9632LBGQZmRQjyifmd2vWLu24XCP8oJEaMYWu8qHsvpP+A@mail.gmail.com \
    --to=sam.habiel@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).