Reputation: 840
I'm trying to use quotes while defining an environment variable.
For example:
setenv SOME_TEMP_ENV "-arg "hello world""
Although Its fails with the following error:
setenv: Too many arguments.
After reading some therds about escaping quotes, I tried the following:
setenv SOME_TEMP_ENV "-arg \"hello world\""
setenv SOME_TEMP_ENV "-arg '"'"'hello world'"'"'"
Also, I could use the following method:
setenv SOME_TEMP_ENV "-arg "'"hello world"'""
But it doesn't fulfill my requirements:
echo $SOME_TEMP_ENV
-arg 'hello world' // should be -arg "hello world"
How can I use quotes in an environment variable?
** EDIT **: I have to use the double quotes around the string because my script for some reason can't read the string is its looks like this: '-arg "hello world"'
Upvotes: 3
Views: 18105
Reputation: 2401
Using single quotes as the outside wrapper will work in both csh (which your question appears to be about) and bash (which your question was tagged as):
'-arg "hello world"'
Upvotes: 2
Reputation: 780871
Use single quotes around the string.
setenv SOME_TEMP_ENV '-arg "hello world"'
Upvotes: 3