public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eliot Moss <moss@cs.umass.edu>
To: "KAVALAGIOS Panagiotis (EEAS-EXT)"
	<Panagiotis.KAVALAGIOS@ext.eeas.europa.eu>,
	Achim Gratz <Stromeko@nexgo.de>,
	"cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: Limitation of setenv for tcsh: Too many arguments
Date: Mon, 11 Jan 2021 10:34:53 -0500	[thread overview]
Message-ID: <2cdbdff1-3656-3d84-5845-af1c8bfdcd91@cs.umass.edu> (raw)
In-Reply-To: <dcc35d6989ac403eb0b70fb80384c2fc@BELBRU-EXMP101.eeas.europa.eu>

On 1/11/2021 3:11 AM, KAVALAGIOS Panagiotis (EEAS-EXT) wrote:
 >> -----Original Message-----
 >> From: Cygwin <cygwin-bounces@cygwin.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@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

  reply	other threads:[~2021-01-11 15:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 10:13 KAVALAGIOS Panagiotis (EEAS-EXT)
2021-01-08 10:38 ` ASSI
2021-01-08 10:55   ` KAVALAGIOS Panagiotis (EEAS-EXT)
2021-01-08 16:19     ` Achim Gratz
2021-01-11  8:11       ` KAVALAGIOS Panagiotis (EEAS-EXT)
2021-01-11 15:34         ` Eliot Moss [this message]
2021-01-08 13:21 ` Eliot Moss
2021-01-08 18:13   ` Brian Inglis

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=2cdbdff1-3656-3d84-5845-af1c8bfdcd91@cs.umass.edu \
    --to=moss@cs.umass.edu \
    --cc=Panagiotis.KAVALAGIOS@ext.eeas.europa.eu \
    --cc=Stromeko@nexgo.de \
    --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).