* Possible syntax failures in /etc/profile
@ 2024-02-15 17:25 Bruce Jerrick
0 siblings, 0 replies; only message in thread
From: Bruce Jerrick @ 2024-02-15 17:25 UTC (permalink / raw)
To: cygwin
(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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-15 17:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-15 17:25 Possible syntax failures in /etc/profile Bruce Jerrick
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).