Limitation of setenv for tcsh: Too many arguments

Eliot Moss
Mon Jan 11 15:34:53 GMT 2021

On 1/11/2021 3:11 AM, KAVALAGIOS Panagiotis (EEAS-EXT) wrote:
 >> -----Original Message-----
 >> From: Cygwin <> On Behalf Of Achim Gratz
 >> Sent: 08 January 2021 17:19
 >> KAVALAGIOS Panagiotis (EEAS-EXT) writes:
 >>> Why do you say both? I don't add /usr/bin anywhere.
 >> Your other example with the $path csh variable doesn't quote $path, which
 >> you must do with the quote modifier rather than actual quotes, so $path:q
 >> because it is an wordlist var.  Also see the -f / -l option for the set builtin of
 >> tcsh if you want to strip out duplicates and take note of some subtle
 >> differences in the default quoting between tcsh and csh if you are trying to
 >> be portable.
 > I might forgot to double quote my variables in my ancient tcsh startup startup scripts using in 
other systems, but of course I have checked the issue on a clean environment before reporting that. 
Forget the tcsh, this is coming from the bash as well the very first time you are running Cygwin:
 > -------------------
 > Copying skeleton files.
 > These files are for the users to personalise their cygwin experience.
 > They will never be overwritten nor automatically updated.
 > './.bashrc' -> '/home/kavalpa//.bashrc'
 > './.bash_profile' -> '/home/kavalpa//.bash_profile'
 > './.inputrc' -> '/home/kavalpa//.inputrc'
 > './.profile' -> '/home/kavalpa//.profile'
 > kavalpa@BELBRU-L1903777 ~
 > $ echo $PATH
 > /usr/local/bin:***/usr/bin***:/cygdrive/c/Program Files/Npm:[snip]:/cygdrive/c/Program 
 > -------------------
 > The issue is enclosed with a three-star notation. I have checked /etc startup files, but I 
couldn't figure out why this is happening. It is also weird the location at the end before user's 
personal paths.

I don't have an answer as to why it's happening, but this bash code will
remove duplicate PATH elements:

while [ -n "${PATH}" ] ; do
   [ -n "${newpath##*@${first}@*}" ] && {
     [ -n "${PATH}" ] && {
newpath="$(/usr/bin/sed -e s/@/:/g <<EOF
unset newpath

This will keep the first instance of each element in PATH.  It will preserve
whether there is a colon at the beginning or end, or two consecutive colons in
the middle.  (Those mean to include the currect directory in PATH at that

I've tested the above code some, but recommend you test it in your environment
first :-) ...

Best wishes - Eliot Moss

More information about the Cygwin mailing list