小编mla*_*mla的帖子

为什么psych yaml interpreter会在80个字符左右添加换行符?

自从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)

ruby yaml syck psych

13
推荐指数
2
解决办法
1990
查看次数

bash set -e函数有双管道

有人可以解释这种行为吗?这对我来说似乎很奇怪.

#!/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)

linux bash

3
推荐指数
1
解决办法
163
查看次数

标签 统计

bash ×1

linux ×1

psych ×1

ruby ×1

syck ×1

yaml ×1