extquote
bashで$'string'と入力すると、文字列の内部のANSI Cライクなエスケープシーケンスを解釈してくれるという機能がある。
で、こちらの本の中でそれはextquoteと呼ぶと書いてあってあったので、呼び名があるんだと思ったのだが。
- 作者: 上田隆一
- 出版社/メーカー: 技術評論社
- 発売日: 2015/05/15
- メディア: Kindle版
- この商品を含むブログを見る
また、bashの機能(extquoteというもの)を使う方法もあるということでした
(以下$'\t'を使う話が続く)
bashのmanには
extquote
If set, $'string' and $"string" quoting is performed within ${parameter} expansions enclosed in double quotes. This option is enabled by default.
とあって、extquoteはこんな感じで、${parameter}の中でも$'string'や$"string"を展開するためのオプションの呼び名のようだ。
$ shopt -u extquote
$ echo $'ab\ncd'
ab
cd
$ echo "${v:-$'ab\ncd'}"
$'ab\ncd'
$ shopt -s extquote
$ echo $'ab\ncd'
ab
cd
$ echo "${v:-$'ab\ncd'}"
ab
cd
$'string'の機能自体はこのオプションによらず利用できている。
$'string'に関しては
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.
と、特に名前は付けられていない。
bashのソースコード的にはansiexpandという関数を呼んでいるので、ansiexpandと呼んだ方が分かりやすいし適切な気がする。まあ、細かい話だけども。