Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 封装为$”的字符串;世界你好。”;_Bash - Fatal编程技术网

Bash 封装为$”的字符串;世界你好。”;

Bash 封装为$”的字符串;世界你好。”;,bash,Bash,我刚刚在Centos 6.5上阅读了/etc/init.d/httpd,注意到所有字符串似乎都被引用为$“Hello World.”。我以前从未见过这种语法,而且我似乎无法通过谷歌找到任何东西 摘录: if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failur

我刚刚在Centos 6.5上阅读了
/etc/init.d/httpd
,注意到所有字符串似乎都被引用为
$“Hello World.”
。我以前从未见过这种语法,而且我似乎无法通过谷歌找到任何东西

摘录:

if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
    RETVAL=6
    echo $"not reloading due to configuration syntax error"
    failure $"not reloading $httpd due to configuration syntax error"

交易是什么?

来自
manbash

   Words of the form $'string' are treated specially.  The word expands to
   string, with backslash-escaped characters replaced as specified by  the
   ANSI  C  standard.  Backslash escape sequences, if present, are decoded
   as follows:
          \a     alert (bell)
          \b     backspace
          \e
          \E     an escape character
          \f     form feed
          \n     new line
          \r     carriage return
          \t     horizontal tab
          \v     vertical tab
          \\     backslash
          \'     single quote
          \"     double quote
          \nnn   the eight-bit character whose value is  the  octal  value
                 nnn (one to three digits)
          \xHH   the  eight-bit  character  whose value is the hexadecimal
                 value HH (one or two hex digits)
          \uHHHH the Unicode (ISO/IEC 10646) character whose value is  the
                 hexadecimal value HHHH (one to four hex digits)
          \UHHHHHHHH
                 the  Unicode (ISO/IEC 10646) character whose value is the
                 hexadecimal value HHHHHHHH (one to eight hex digits)
          \cx    a control-x character

   The expanded result is single-quoted, as if the  dollar  sign  had  not
   been present.

   A double-quoted string preceded by a dollar sign ($"string") will cause
   the string to be translated according to the current  locale.   If  the
   current  locale  is  C  or  POSIX,  the dollar sign is ignored.  If the
   string is translated and replaced, the replacement is double-quoted.

这意味着字符串可以根据所使用的语言环境进行翻译?(如果有翻译,当然)谢谢!通过其他渠道浏览,也发现了一些关于它是如何实现的文档:这里有一篇关于它的文章:@tripleee在三年后标记为副本?在一个地方收集答案而不是在网站上散布副本是一个长期的维护过程。理想情况下,应该有人更早地注意到复制,但这并不意味着现在对它进行标记是没有用的。