與tcsh的測試,這下在tcsh
所有的工作來完成各種結果:
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 ('\'')
,以瞭解這些由shell來解釋,無參數運行alias
:
% 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'
圓括號中的任何內容都在子外殼中運行。如果你試圖設置環境變量,這會很糟糕,但是大多數情況下是不相關的。
最後,這裏就是例子實際上做:
% t; u; v; w; x; y; z
hello world
hello world
hello world
;hello; world
"hello world"
hello world
hello world
最後兩個不需要引號。用單引號代替雙引號怎麼樣? – 2008-12-20 03:19:39