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 -- 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 |
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 -- 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 |
> -----Original Message-----
> From: Cygwin <[hidden email]> 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 -- 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 |
In reply to this post by KAVALAGIOS Panagiotis (EEAS-EXT)
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 -- 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 |
In reply to this post by KAVALAGIOS Panagiotis (EEAS-EXT)
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 -- 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 |
In reply to this post by Eliot Moss
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.] -- 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 |
In reply to this post by Achim Gratz
> -----Original Message-----
> From: Cygwin <[hidden email]> 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 -- 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 |
On 1/11/2021 3:11 AM, KAVALAGIOS Panagiotis (EEAS-EXT) wrote:
>> -----Original Message----- >> From: Cygwin <[hidden email]> 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 -- 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 |
Free forum by Nabble | Edit this page |