Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad : modifier in $ (/)

Tags:

shell

tcsh

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.

like image 304
elif mutlu Avatar asked Dec 05 '16 06:12

elif mutlu


2 Answers

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"
like image 165
Inian Avatar answered Oct 26 '22 11:10

Inian


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

like image 4
Ruslan Osmanov Avatar answered Oct 26 '22 11:10

Ruslan Osmanov