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.

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest