delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/01/11/10:35:52

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C7018386EC5B
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=cs.umass.edu
Authentication-Results: sourceware.org;
spf=pass smtp.mailfrom=moss AT cs DOT umass DOT edu
Subject: Re: Limitation of setenv for tcsh: Too many arguments
To: "KAVALAGIOS Panagiotis (EEAS-EXT)"
<Panagiotis DOT KAVALAGIOS AT ext DOT eeas DOT europa DOT eu>,
Achim Gratz <Stromeko AT nexgo DOT de>,
"cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
References: <0d66260ff1314bf693caa6cbb6647547 AT BELBRU-EXMP101 DOT eeas DOT europa DOT eu>
<871revlnmg DOT fsf AT Otto DOT invalid>
<63cabc18e6f845a7aaae49ce447cc152 AT BELBRU-EXMP101 DOT eeas DOT europa DOT eu>
<87eeiv9zat DOT fsf AT Rainer DOT invalid>
<dcc35d6989ac403eb0b70fb80384c2fc AT BELBRU-EXMP101 DOT eeas DOT europa DOT eu>
From: Eliot Moss <moss AT cs DOT umass DOT edu>
Message-ID: <2cdbdff1-3656-3d84-5845-af1c8bfdcd91@cs.umass.edu>
Date: Mon, 11 Jan 2021 10:34:53 -0500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <dcc35d6989ac403eb0b70fb80384c2fc@BELBRU-EXMP101.eeas.europa.eu>
X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL,
KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
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>
Reply-To: moss AT cs DOT umass DOT edu
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

On 1/11/2021 3:11 AM, KAVALAGIOS Panagiotis (EEAS-EXT) wrote:
 >> -----Original Message-----
 >> From: Cygwin <cygwin-bounces AT cygwin DOT com> 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 AT BELBRU-L1903777 ~
 > $ echo $PATH
 > /usr/local/bin:***/usr/bin***:/cygdrive/c/Program Files/Npm:[snip]:/cygdrive/c/Program 
Files/PHP/composer/bin:***/usr/bin***:/cygdrive/c/Users/kavalpa/AppData/Local/Microsoft/WindowsApps
 > -------------------
 >
 > 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:

newpath="@"
while [ -n "${PATH}" ] ; do
   first="${PATH%%:*}"
   PATH="${PATH#${first}}"
   [ -n "${newpath##*@${first}@*}" ] && {
     newpath="${newpath}${first}"
     [ -n "${PATH}" ] && {
       newpath="${newpath}@"
     }
   }
   PATH="${PATH#:}"
done
newpath="$(/usr/bin/sed -e s/@/:/g <<EOF
${newpath#@}
EOF
)"
PATH="${newpath}"
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
point.)

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

Best wishes - Eliot Moss
--
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