OILS / spec / blog-other1.test.sh View on Github | oilshell.org

57 lines, 10 significant
1#
2# From:
3#
4# https://lobste.rs/s/xhtim1/problems_with_shells_test_builtin_what
5# http://alangrow.com/blog/shell-quirk-assign-from-heredoc
6
7## suite: disabled
8
9#### Blog Post Example
10paths=`tr '\n' ':' | sed -e 's/:$//'`<<EOPATHS
11/foo
12/bar
13/baz
14EOPATHS
15echo "$paths"
16## stdout: /foo:/bar:/baz
17
18#### Blog Post Example Fix
19paths=`tr '\n' ':' | sed -e 's/:$//'<<EOPATHS
20/foo
21/bar
22/baz
23EOPATHS`
24echo "$paths"
25## stdout-json: "/foo\n/bar\n/baz\n"
26
27#### Rewrite of Blog Post Example
28paths=$(tr '\n' ':' | sed -e 's/:$//' <<EOPATHS
29/foo
30/bar
31/baz
32EOPATHS
33)
34echo "$paths"
35## stdout-json: "/foo\n/bar\n/baz\n"
36
37#### Simpler example
38foo=`cat`<<EOM
39hello world
40EOM
41echo "$foo"
42## stdout: hello world
43
44#### ` after here doc delimiter
45foo=`cat <<EOM
46hello world
47EOM`
48echo "$foo"
49## stdout: hello world
50
51#### ` on its own line
52foo=`cat <<EOM
53hello world
54EOM
55`
56echo "$foo"
57## stdout: hello world