From: Brian Inglis <Brian.Inglis@Shaw.ca>
To: cygwin@cygwin.com
Subject: Re: Limitation of setenv for tcsh: Too many arguments
Date: Fri, 8 Jan 2021 11:13:48 -0700 [thread overview]
Message-ID: <36f296b6-55ff-cca5-10dc-4e1df7a68147@Shaw.ca> (raw)
In-Reply-To: <4a7542e2-9f38-9e72-3229-ca39feab66d1@cs.umass.edu>
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.]
prev parent reply other threads:[~2021-01-08 18:13 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
2021-01-08 13:21 ` Eliot Moss
2021-01-08 18:13 ` Brian Inglis [this message]
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=36f296b6-55ff-cca5-10dc-4e1df7a68147@Shaw.ca \
--to=brian.inglis@shaw.ca \
--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).