我想etc/environment在 AWS Linux AMI 2013.03 上存储系统范围的环境变量。在这个例子中,我试图存储短语“#hello”。请参阅下面的示例。echo $control产生
hello
我期望echo $test0(如下)产生:
#hello
但它会产生一个空行。以下是我输入的测试列表/etc/environment:
control="hello"test0="#hello"test1="h\\#ello"test2="h\#ello"test3="h//#ello"test4="h/#ello"test5=h#ellotest6=h\\#ellotest7=h\#ellotest8=h//#ellotest9=h/#ellotest10='h#ello'test11='h\\#ello'test12='h\#ello'test13='h//#ello'test14='h/#ello'如果我注销然后重新登录机器,它将正确解析 /etc/environment.conf 。控制条件传递echo $control。但是,没有一个测试用例正确响应。在每种情况下,哈希 (#) 之外的字符串要么被压缩,要么被忽略。例如,echo $test5产生h. 有没有更好的方法来正确逃脱#?
有趣的是,如果我执行source /etc/environment,那么所有的作品如预期的确都echo $control和echo $test产生预期的结果。但是,在注销/登录时,问题又回来了......