SETENV: Bad : modifier in $ ($)
Asked Answered
G

5

6

I am using the tcsh terminal in Linux. In the other terminal I normally used I set the path to some license file as follows:

  export PATH="$PATH:$MODEL_TECH"

Tcsh shell does not recognise this command so I tried the following:

  setenv PATH "$PATH:$MODEL_TECH"
  set PATH "$PATH:$MODEL_TECH"
  setenv PATH=("$PATH:$MODEL_TECH")

But then I always get the following error:

Bad : modifier in $ ($).

What be also great if someone could help me here out quickly, tried quite a few combinations but nothing works.

Gerfen answered 7/3, 2011 at 11:17 Comment(0)
M
5

Drop the =

setenv LICENSE_FILE "/usr/local/softwarex/license.dat"

From the man page for tcsh:

   setenv [name [value]]

   Without  arguments, prints the names and values of all environ‐
   ment variables.  Given name, sets the environment variable name
   to value or, without value, to the null string.
Mechanotherapy answered 7/3, 2011 at 11:18 Comment(0)
K
5

Put curly braces around the variable names:

setenv PATH ${PATH}:${foo}

or use this form:

set path = ($path $foo)
Kimberykimble answered 7/3, 2011 at 11:44 Comment(2)
Right. csh/tcsh uses the : character for modifiers; for example $var:t gives you the root of the filename $var (by deleting the .whatever extension). If you write "$PATH:$MODEL_TECH" the shell thinks the '$' is part of a modifier for $PATH (which it doesn't recognize). The curly braces separate the name from the following ':'. The set path = ... form sets the corresponding shell variable $path, which is tied to the environment variable $PATH. man tcsh for more information.Chantry
Although not stated, an explicit string will work as well e.g. setenv PATH ${PATH}:/foo/barCordless
S
2

Try setenv LICENSE_FILE /usr/local/softwarex/license.dat. This should be documented in the man page somewhere on your system, so try reading up in man tcsh; tcsh is a very different beast from bash and friends. If the relevant man page isn't available on your system for some reason, here's the first man tcsh I found.

Straitlaced answered 7/3, 2011 at 11:19 Comment(3)
Great, that works fine but it seems there are still problems when I wanna set a path, I added this to my post. I get then a bad modifier error.Gerfen
tcsh syntax for setting the PATH is different than sh variants. Do you have a good reason for using tcsh? Unless there is a very compelling reason, it's probably better to continue using an sh-variant.Cosy
@Gerfen Is $MODEL_TECH set?Straitlaced
C
0

On a tcsh shell the path or any environment variable can be appended as below:

setenv PATH $PATH":$NEWPATH"
Carmelitacarmelite answered 14/5, 2014 at 18:56 Comment(0)
B
-1

If it's not working use this:

setenv PATH ${PATH}:/.../../../
Brietta answered 30/4, 2015 at 13:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.