Limitation of setenv for tcsh: Too many arguments

Brian Inglis Brian.Inglis@Shaw.ca
Fri Jan 8 18:13:48 GMT 2021


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


More information about the Cygwin mailing list