The following all work in tcsh
to accomplish various results:
alias t echo hello world # you may not actually need any quotes
alias u 'echo "hello world"' # nested quotes of different types
alias v echo\ \"hello\ world\" # escape everything
alias w echo '\;'hello'";"' world # quote/escape problem areas only
alias x 'echo \"hello world\"' # single quote and escape for literal "
alias y "echo "\""hello world"\" # unquote, escaped quote, quote ("\"")
alias z 'echo '\''hello world'\' # same goes for single quotes ('\'')
To see how these are interpreted by the shell, run alias
with no arguments:
% alias
t (echo hello world)
u echo "hello world"
v echo "hello world"
w (echo \;hello";" world)
x echo \"hello world\"
y echo "hello world"
z echo 'hello world'
Anything in parentheses is run in a subshell. This would be bad if you're trying to set environment variables, but mostly irrelevant otherwise.
Finally, here's what the examples actually do:
% t; u; v; w; x; y; z
hello world
hello world
hello world
;hello; world
"hello world"
hello world
hello world