elif mutlu
elif mutlu

Reputation: 113

Bad : modifier in $ (/)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/my/lib

error:

Bad : modifier in $ (/)

echo $SHELL

/bin/tcsh

I want to add my library to LD_LIBRARY_PATH variable. But Gives the above error.

Upvotes: 11

Views: 33803

Answers (2)

Inian
Inian

Reputation: 85580

As Ignacio Vazquez-Abrams, pointed out you need to set environment variable in tcsh syntax as

setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:"/home/my/lib"

Upvotes: 15

Ruslan Osmanov
Ruslan Osmanov

Reputation: 21492

# Assign empty string to LD_LIBRARY_PATH, if the variable is undefined
[ ${?LD_LIBRARY_PATH} -eq 0 ] && setenv LD_LIBRARY_PATH ""

setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/home/my/lib"

Checking if the Variable is Defined

If the variable was not previously defined, the simple setenv LD_LIBRARY_PATH value command will fail with an error like LD_LIBRARY_PATH: Undefined variable.. To prevent this, check the value of ${?LD_LIBRARY_PATH} (substitutes the string 1 if name is set, 0 if it is not) and set a default value as it is shown above.

Using Double Quotes

Also note the use of double quotes. Suppose the variable contains spaces, e.g.:

setenv LD_LIBRARY_PATH "/home/user with spaces/lib"

Then the command without quotes:

setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/my/lib

will fail with the following error:

setenv: Too many arguments. 

In double quotes, however, the value is passed to the command as a single word.

Upvotes: 4

Related Questions