自从ruby 1.9.3以来,Psych是默认的yaml引擎
为什么,为什么心理在其输出中添加换行符?请查看以下示例.
ruby -v # => ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux]
require 'yaml'
"this absolutely normal sentence is more than eighty characters long because it IS".to_yaml
# => "--- this absolutely normal sentence is more than eighty characters long because it\n IS\n...\n"
YAML::ENGINE.yamler = 'syck'
"this absolutely normal sentence is more than eighty characters long because it IS".to_yaml
# => "--- this absolutely normal sentence is more than eighty characters long because it IS\n"
Run Code Online (Sandbox Code Playgroud) 有人可以解释这种行为吗?这对我来说似乎很奇怪.
#!/bin/bash
set -e
_func() {
cat non-existant-file
return 0
}
_func || echo "Not seen since _func returned zero"
_func
echo "Not seen since _func returned non-zero"
Run Code Online (Sandbox Code Playgroud)
输出(GNU bash,版本4.3.42(1)-release(x86_64-pc-linux-gnu)):
$ bash func.sh
cat: non-existant-file: No such file or directory
cat: non-existant-file: No such file or directory
$
Run Code Online (Sandbox Code Playgroud)