public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Limitation of setenv for tcsh: Too many arguments
@ 2021-01-08 10:13 KAVALAGIOS Panagiotis (EEAS-EXT)
  2021-01-08 10:38 ` ASSI
  2021-01-08 13:21 ` Eliot Moss
  0 siblings, 2 replies; 8+ messages in thread
From: KAVALAGIOS Panagiotis (EEAS-EXT) @ 2021-01-08 10:13 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

Dear all,

There is a limitation for tcsh (setenv: Too many arguments) to set the PATH environmental variable as you can see in the attached file with the steps to reproduce it. It probably looks like tcsh limitation and not Cygwin. The "set path=( ${HOME}/bin $path)" is not complaining and sets the path, but it also interprets the space in the paths as a separator. The only Cygwin related issue is probably the /usr/bin that it is added twice. Any workarounds?

Panos

Application Architect
CONSULIAT (under contract with the EEAS)
BA.BS.3.IS
Office: EEAS B100 Floor 5 Area 048
Rue Belliard 100, 1000 Brussels
Phone: +32 2 584 6017


[-- Attachment #2: tcsh-setenv-issue.txt --]
[-- Type: text/plain, Size: 5698 bytes --]

kavalpa@BELBRU-L1903777 ~
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/Java/jdk/bin:/cygdrive/c/Program Files/Npm:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/Webex/Webex/Applications:/cygdrive/c/Program Files/Oracle/Instant Client:/cygdrive/c/Program Files/PuTTY:/cygdrive/c/Program Files/Apache/apache-ant/bin:/cygdrive/c/Program Files/Apache/apache-maven/bin:/cygdrive/c/Program Files/Apache/apache-httpd/bin:/cygdrive/c/Program Files (x86)/Bitvise SSH Client:/cygdrive/c/Program Files/MySQL/MySQL Server/bin:/cygdrive/c/Program Files/Node.js:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN64:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN32:/cygdrive/c/Program Files/Sysinternals:/cygdrive/c/Program Files/DIGIT/WLST-API/bin:/cygdrive/c/Program Files (x86)/Oracle/Instant Client:/cygdrive/c/Program Files/Oracle/TNSPing:/cygdrive/c/Program Files/ZeroTurnaround/JRebel/bin:/cygdrive/c/DEV/PHP/php:/cygdrive/c/Program Files/PHP/composer/bin:/usr/bin:/cygdrive/c/Users/kavalpa/AppData/Local/Microsoft/WindowsApps

kavalpa@BELBRU-L1903777 ~
$ tcsh
kavalpa@BELBRU-L1903777:[19] ~ > echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/Java/jdk/bin:/cygdrive/c/Program Files/Npm:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/Webex/Webex/Applications:/cygdrive/c/Program Files/Oracle/Instant Client:/cygdrive/c/Program Files/PuTTY:/cygdrive/c/Program Files/Apache/apache-ant/bin:/cygdrive/c/Program Files/Apache/apache-maven/bin:/cygdrive/c/Program Files/Apache/apache-httpd/bin:/cygdrive/c/Program Files (x86)/Bitvise SSH Client:/cygdrive/c/Program Files/MySQL/MySQL Server/bin:/cygdrive/c/Program Files/Node.js:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN64:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN32:/cygdrive/c/Program Files/Sysinternals:/cygdrive/c/Program Files/DIGIT/WLST-API/bin:/cygdrive/c/Program Files (x86)/Oracle/Instant Client:/cygdrive/c/Program Files/Oracle/TNSPing:/cygdrive/c/Program Files/ZeroTurnaround/JRebel/bin:/cygdrive/c/DEV/PHP/php:/cygdrive/c/Program Files/PHP/composer/bin:/usr/bin:/cygdrive/c/Users/kavalpa/AppData/Local/Microsoft/WindowsApps
kavalpa@BELBRU-L1903777:[20] ~ > setenv PATH ${HOME}/bin:${PATH}
setenv: Too many arguments.
kavalpa@BELBRU-L1903777:[21] ~ > exit
exit

kavalpa@BELBRU-L1903777 ~
$ export PATH=${HOME}/bin:${PATH}

kavalpa@BELBRU-L1903777 ~
$ echo $PATH
/home/kavalpa/bin:/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/Java/jdk/bin:/cygdrive/c/Program Files/Npm:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/Webex/Webex/Applications:/cygdrive/c/Program Files/Oracle/Instant Client:/cygdrive/c/Program Files/PuTTY:/cygdrive/c/Program Files/Apache/apache-ant/bin:/cygdrive/c/Program Files/Apache/apache-maven/bin:/cygdrive/c/Program Files/Apache/apache-httpd/bin:/cygdrive/c/Program Files (x86)/Bitvise SSH Client:/cygdrive/c/Program Files/MySQL/MySQL Server/bin:/cygdrive/c/Program Files/Node.js:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN64:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN32:/cygdrive/c/Program Files/Sysinternals:/cygdrive/c/Program Files/DIGIT/WLST-API/bin:/cygdrive/c/Program Files (x86)/Oracle/Instant Client:/cygdrive/c/Program Files/Oracle/TNSPing:/cygdrive/c/Program Files/ZeroTurnaround/JRebel/bin:/cygdrive/c/DEV/PHP/php:/cygdrive/c/Program Files/PHP/composer/bin:/usr/bin:/cygdrive/c/Users/kavalpa/AppData/Local/Microsoft/WindowsApps

kavalpa@BELBRU-L1903777 ~
$ tcsh
kavalpa@BELBRU-L1903777:[22] ~ > echo $PATH
/home/kavalpa/bin:/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/Java/jdk/bin:/cygdrive/c/Program Files/Npm:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/Webex/Webex/Applications:/cygdrive/c/Program Files/Oracle/Instant Client:/cygdrive/c/Program Files/PuTTY:/cygdrive/c/Program Files/Apache/apache-ant/bin:/cygdrive/c/Program Files/Apache/apache-maven/bin:/cygdrive/c/Program Files/Apache/apache-httpd/bin:/cygdrive/c/Program Files (x86)/Bitvise SSH Client:/cygdrive/c/Program Files/MySQL/MySQL Server/bin:/cygdrive/c/Program Files/Node.js:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN64:/cygdrive/c/Program Files (x86)/SAP BusinessObjects/sqlanywhere/BIN32:/cygdrive/c/Program Files/Sysinternals:/cygdrive/c/Program Files/DIGIT/WLST-API/bin:/cygdrive/c/Program Files (x86)/Oracle/Instant Client:/cygdrive/c/Program Files/Oracle/TNSPing:/cygdrive/c/Program Files/ZeroTurnaround/JRebel/bin:/cygdrive/c/DEV/PHP/php:/cygdrive/c/Program Files/PHP/composer/bin:/usr/bin:/cygdrive/c/Users/kavalpa/AppData/Local/Microsoft/WindowsApps
kavalpa@BELBRU-L1903777:[23] ~ >

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Limitation of setenv for tcsh: Too many arguments
  2021-01-08 10:13 Limitation of setenv for tcsh: Too many arguments KAVALAGIOS Panagiotis (EEAS-EXT)
@ 2021-01-08 10:38 ` ASSI
  2021-01-08 10:55   ` KAVALAGIOS Panagiotis (EEAS-EXT)
  2021-01-08 13:21 ` Eliot Moss
  1 sibling, 1 reply; 8+ messages in thread
From: ASSI @ 2021-01-08 10:38 UTC (permalink / raw)
  To: cygwin

KAVALAGIOS Panagiotis (EEAS-EXT) writes:
> There is a limitation for tcsh (setenv: Too many arguments) to set the
> PATH environmental variable as you can see in the attached file with
> the steps to reproduce it. It probably looks like tcsh limitation and
> not Cygwin. The "set path=( ${HOME}/bin $path)" is not complaining and
> sets the path, but it also interprets the space in the paths as a
> separator. The only Cygwin related issue is probably the /usr/bin that
> it is added twice. Any workarounds?

Both problems are a failure on your part to quote the arguments
correctly.  Consult the documentation for the respective shell to find
enlightenment.

As an aside, it is highly unlikely that you'd actually want to set up
your PATH like that.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Limitation of setenv for tcsh: Too many arguments
  2021-01-08 10:38 ` ASSI
@ 2021-01-08 10:55   ` KAVALAGIOS Panagiotis (EEAS-EXT)
  2021-01-08 16:19     ` Achim Gratz
  0 siblings, 1 reply; 8+ messages in thread
From: KAVALAGIOS Panagiotis (EEAS-EXT) @ 2021-01-08 10:55 UTC (permalink / raw)
  To: cygwin

> -----Original Message-----
> From: Cygwin <cygwin-bounces@cygwin.com> On Behalf Of ASSI
> Sent: 08 January 2021 11:39
> 
> KAVALAGIOS Panagiotis (EEAS-EXT) writes:
> > There is a limitation for tcsh (setenv: Too many arguments) to set the
> > PATH environmental variable as you can see in the attached file with
> > the steps to reproduce it. It probably looks like tcsh limitation and
> > not Cygwin. The "set path=( ${HOME}/bin $path)" is not complaining and
> > sets the path, but it also interprets the space in the paths as a
> > separator. The only Cygwin related issue is probably the /usr/bin that
> > it is added twice. Any workarounds?
> 
> Both problems are a failure on your part to quote the arguments correctly.
> Consult the documentation for the respective shell to find enlightenment.

Indeed, I forgot the double quotes. That works:

setenv PATH "${HOME}/bin:${PATH}"

I confused the message like a length limitation and not for the number of input arguments.

Why do you say both? I don't add /usr/bin anywhere.

> As an aside, it is highly unlikely that you'd actually want to set up your PATH
> like that.

Care to explain? How else can I add in the path custom personal commands?

Panos

Application Architect
CONSULIAT (under contract with the EEAS)
BA.BS.3.IS
Office: EEAS B100 Floor 5 Area 048
Rue Belliard 100, 1000 Brussels
Phone: +32 2 584 6017


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Limitation of setenv for tcsh: Too many arguments
  2021-01-08 10:13 Limitation of setenv for tcsh: Too many arguments KAVALAGIOS Panagiotis (EEAS-EXT)
  2021-01-08 10:38 ` ASSI
@ 2021-01-08 13:21 ` Eliot Moss
  2021-01-08 18:13   ` Brian Inglis
  1 sibling, 1 reply; 8+ messages in thread
From: Eliot Moss @ 2021-01-08 13:21 UTC (permalink / raw)
  To: KAVALAGIOS Panagiotis (EEAS-EXT), cygwin

On 1/8/2021 5:13 AM, KAVALAGIOS Panagiotis (EEAS-EXT) wrote:
 > Dear all,
 >
 > There is a limitation for tcsh (setenv: Too many arguments) to set the PATH environmental 
variable as you can see in the attached file with the steps to reproduce it. It probably looks like 
tcsh limitation and not Cygwin. The "set path=( ${HOME}/bin $path)" is not complaining and sets the 
path, but it also interprets the space in the paths as a separator. The only Cygwin related issue is 
probably the /usr/bin that it is added twice. Any workarounds?

I saw another response, but will add that I typically do something more like:

set PATH="${HOME}/bin:${PATH}"

THat takes care of quoting.  However, you want to avoid duplicate entries.
Something like this helps with that:

[ -z "${PATH##*${HOME}/bin:*}" ] || {
   PATH="${HOME}/bin:${PATH}"
}

I suppose it is slightly dangerous in that it would also match
/foo/${HOME}/bin, but ${HOME} is absolute and such a match seems unlikely.
Still, you could do:

[ -z "${PATH##${HOME}/bin:*}" ]

to check if it is first on the path, and

[ -z "${PATH##*:${HOME}/bin:*}" ]

to see if it is in the middle, and

[ -z "${PATH##*:${HOME}/bin}" ]

to see if it as at the end.  This leads to:

[ -z "${PATH##${HOME}/bin:*}" ] || [ -z "${PATH##*:${HOME}/bin:*}" ] || [ -z 
"${PATH##*:${HOME}/bin}" ] || {
   PATH="${HOME}/bin:$PATH}"
}

Because of the three first/middle/end possibilities, this is what comes to
mind.  _Maybe_ you could get a more elegant solution using bash arrays, but
this is not that long as a piece of bash code.

Regards - Eliot Moss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Limitation of setenv for tcsh: Too many arguments
  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)
  0 siblings, 1 reply; 8+ messages in thread
From: Achim Gratz @ 2021-01-08 16:19 UTC (permalink / raw)
  To: cygwin

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.

>> As an aside, it is highly unlikely that you'd actually want to set up your PATH
>> like that.
>
> Care to explain? How else can I add in the path custom personal commands?

I just don't think it's a good idea to have all that stuff in PATH,
especially since PATH in Windows determines library search order and
there is a high propensity for libraries with the same name getting
reachable via PATH for your example.  I tend to stay within Cygwin as
much as possible and have wrapper scripts setting up the environment for
all other commands.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Limitation of setenv for tcsh: Too many arguments
  2021-01-08 13:21 ` Eliot Moss
@ 2021-01-08 18:13   ` Brian Inglis
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Inglis @ 2021-01-08 18:13 UTC (permalink / raw)
  To: cygwin

On 2021-01-08 06:21, Eliot Moss wrote:
> On 1/8/2021 5:13 AM, KAVALAGIOS Panagiotis (EEAS-EXT) wrote:
>  > Dear all,
>  >
>  > There is a limitation for tcsh (setenv: Too many arguments) to set the PATH 
> environmental variable as you can see in the attached file with the steps to 
> reproduce it. It probably looks like tcsh limitation and not Cygwin. The "set 
> path=( ${HOME}/bin $path)" is not complaining and sets the path, but it also 
> interprets the space in the paths as a separator. The only Cygwin related issue 
> is probably the /usr/bin that it is added twice. Any workarounds?
> 
> I saw another response, but will add that I typically do something more like:
> 
> set PATH="${HOME}/bin:${PATH}"
> 
> THat takes care of quoting.  However, you want to avoid duplicate entries.
> Something like this helps with that:
> 
> [ -z "${PATH##*${HOME}/bin:*}" ] || {
>    PATH="${HOME}/bin:${PATH}"
> }
> 
> I suppose it is slightly dangerous in that it would also match
> /foo/${HOME}/bin, but ${HOME} is absolute and such a match seems unlikely.
> Still, you could do:
> 
> [ -z "${PATH##${HOME}/bin:*}" ]
> 
> to check if it is first on the path, and
> 
> [ -z "${PATH##*:${HOME}/bin:*}" ]
> 
> to see if it is in the middle, and
> 
> [ -z "${PATH##*:${HOME}/bin}" ]
> 
> to see if it as at the end.  This leads to:
> 
> [ -z "${PATH##${HOME}/bin:*}" ] || [ -z "${PATH##*:${HOME}/bin:*}" ] || [ -z 
> "${PATH##*:${HOME}/bin}" ] || {
>    PATH="${HOME}/bin:$PATH}"
> }
> 
> Because of the three first/middle/end possibilities, this is what comes to
> mind.  _Maybe_ you could get a more elegant solution using bash arrays, but
> this is not that long as a piece of bash code.

Please consider the subject line - he is using tcsh in which path is an array - 
Achim followed up with hints on handling the issues under that shell! ;^>

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Limitation of setenv for tcsh: Too many arguments
  2021-01-08 16:19     ` Achim Gratz
@ 2021-01-11  8:11       ` KAVALAGIOS Panagiotis (EEAS-EXT)
  2021-01-11 15:34         ` Eliot Moss
  0 siblings, 1 reply; 8+ messages in thread
From: KAVALAGIOS Panagiotis (EEAS-EXT) @ 2021-01-11  8:11 UTC (permalink / raw)
  To: Achim Gratz, cygwin

> -----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.

> >> As an aside, it is highly unlikely that you'd actually want to set up
> >> your PATH like that.
> >
> > Care to explain? How else can I add in the path custom personal
> commands?
> 
> I just don't think it's a good idea to have all that stuff in PATH, especially since
> PATH in Windows determines library search order and there is a high
> propensity for libraries with the same name getting reachable via PATH for
> your example.  I tend to stay within Cygwin as much as possible and have
> wrapper scripts setting up the environment for all other commands.

There is a point with the DLLs in the path of Windows, but where do you store your wrapper scripts? Because I usually place them in my ~/bin, which is the only solution when you don't have admin rights on your machine. When I do have admin rights, I usually place them in /usr/local/bin.

Panos

Application Architect
CONSULIAT (under contract with the EEAS)
BA.BS.3.IS
Office: EEAS B100 Floor 5 Area 048
Rue Belliard 100, 1000 Brussels
Phone: +32 2 584 6017


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Limitation of setenv for tcsh: Too many arguments
  2021-01-11  8:11       ` KAVALAGIOS Panagiotis (EEAS-EXT)
@ 2021-01-11 15:34         ` Eliot Moss
  0 siblings, 0 replies; 8+ messages in thread
From: Eliot Moss @ 2021-01-11 15:34 UTC (permalink / raw)
  To: KAVALAGIOS Panagiotis (EEAS-EXT), Achim Gratz, cygwin

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-11 15:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 10:13 Limitation of setenv for tcsh: Too many arguments 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
2021-01-08 13:21 ` Eliot Moss
2021-01-08 18:13   ` Brian Inglis

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).