delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/02/15/12:26:00

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79613386C58A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1708017959;
bh=eMZzRffpuABpUtlucXBf9RQuOhk6mqywRVJdfR2A718=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=NzqH/ODfjYIzysY3U3efYpuXl76NdGFHW65DxyTfTHVFbPl6OEG6pTNPkRfS5VGZS
0UcY9Z0dEWjtJCHmpV4ObiRUTt7kGIEPNBk4cQ2uXNR3qpKDfg5AcEVJYQp9+Zn94c
j0IEIwqmFx3btyWOrL6sNHjxpovg4DRBi/uAuk4U=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 436AD384CB97
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 436AD384CB97
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708017940; cv=none;
b=go2JzQzie8pPln0dVj7UVQXmXWwb/iczOF/1uYfnFfH6388wyMumw3ejokZ/poi4Vn1XgGMl7XsA0kY38SvNF0CUc0VXyRcgd6tgTfW0IYtmmebkTR5iqfjhD4109KIITBvpq8uKtU5Py/70SqD0fEOs7UAvIertj7wG2Z5z70I=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1708017940; c=relaxed/simple;
bh=h2Z4M2XFTBf7SUIRRpOI3rvcQZoomUPm096pQ+hQUXM=;
h=DKIM-Signature:To:From:Subject:Message-ID:Date:MIME-Version;
b=JykK3fVXcP/UDtZr98zHsrU8nNPpLR4wppG8sNi+J4E9SOR0Tn1OpOd/rb5D66VRyHHsNb4ZsO0fgY4A4RBL5AmvOGHhpYkJlHo1HYuo2xH8nI+TOZRUVTcMvY5S5POnokD4+jq2OSKrHSam+i2pOuP4Ov/OEW/Ivkq52i3YZhc=
ARC-Authentication-Results: i=1; server2.sourceware.org
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1708017938; x=1708622738;
h=content-language:content-transfer-encoding:mime-version:user-agent
:date:message-id:subject:from:to:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=h2Z4M2XFTBf7SUIRRpOI3rvcQZoomUPm096pQ+hQUXM=;
b=WIYQ5HYyVuuZTkzl39g8rlAIQlieyFSUbNhX+xd+8tBa6VeEXJecPHV5CV5/tVTfcu
jZDhBF7npdgnv4PWENLvxLEVWiSS07Y5iHMMTieyh7FmorWahzAbRNR9JxZ5LXyAtWcq
yJw+Rn3jARNfnOQtiTZSUs0/EilTLMo4FaSKAsPpRZnu7WiGpoDfvunJ5HoKr1DJigbp
rlw7YVsY78olmCnpoa+mT7hKNffK7OcYpn6ypmHa8wzoxQagaVKgvu7AAHHYuSaQ63LR
pA5ofxCwXq7ftEo27r433jv+RmycoNABFOv6qGHGgy2w1o+t+q1EK0Gk1VvQeGyL8IL2
Ewvg==
X-Gm-Message-State: AOJu0Yzb7axg0b/07PSiLhCNPTb64men3i0R5/hCodG9ptbF5bIpfH2n
eG0kap/2En11b/vnjqZkCdCj4zpxau/LVFY/ORMUdGsHeShI1Y5Y3Das5Mls
X-Google-Smtp-Source: AGHT+IGYPN2Cr99CZorg4oO6WVNCZ300tvCFC8cVvs0CBCkvDreZopYjDOdq4HT/Xu1jsuiVC4CwAg==
X-Received: by 2002:a05:6a20:c78d:b0:19e:ba42:4ed9 with SMTP id
hk13-20020a056a20c78d00b0019eba424ed9mr3745864pzb.1.1708017937759;
Thu, 15 Feb 2024 09:25:37 -0800 (PST)
To: cygwin AT cygwin DOT com
Subject: Possible syntax failures in /etc/profile
Message-ID: <1ea425ab-8e78-e42b-5ab5-5a6a9c82f96f@gmail.com>
Date: Thu, 15 Feb 2024 09:25:35 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.8.0
MIME-Version: 1.0
X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00, BODY_8BITS,
DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF,
FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,
SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Bruce Jerrick via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Bruce Jerrick <bmj001 AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 41FHQ0q3001382

(Forgive me if this is a duplicate -- my first attempt seems to have
slipped into a black hole.)

In the snippet below from /etc/defaults/etc/profile (base-files-4.3-3),
the '[]' tests can fail with the syntax error:

  -bash: [: =: unary operator expected

if CYGWIN_USEWINPATH or CYGWIN_NOWINPATH are set to a null (empty)
string.  (There's nothing on the left side of the '='.)
Any indication of an error seems to slip into a black hole somewhere.

The fix would be either to surround their expansions in double-quotes,
or use ':-' in place of '-' in their expansions (i.e., do the
substitition if unset or null, not just unset).  (Per 'man sh',
"Parameter Expansion".)

The code is as follows (expansions marked with '*'):

   # setting CYGWIN_USEWINPATH non-empty in the system variables
   # assumes that you've already set up PATH so that Cygwin works
   # correctly -- no further alteration is done
*  if [ ${CYGWIN_USEWINPATH-pathprepend} = "pathprepend" ] ; then
     # setting CYGWIN_NOWINPATH non-empty in the system variables
     # prevents use of the existing PATH and a clean PATH just for
     # Cygwin is set up -- you need to add any extra path components
     # you need in your personal startup files
*    if [ ${CYGWIN_NOWINPATH-addwinpath} = "addwinpath" ] ; then
         PATH="/usr/local/bin:/usr/bin${PATH:+:${PATH}}"
     else
         PATH="/usr/local/bin:/usr/bin"
     fi
   fi

P.S.: When testing, note that the code is effectively execute-once,
due to the PROFILEREAD variable.


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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