Permalink
Please sign in to comment.
Browse files
Testing a here doc + command sub example from lobste.rs / blog post.
- Loading branch information...
Showing
with
42 additions
and 0 deletions.
- +34 −0 spec/blog-other1.test.sh
- +3 −0 test/spec-runner.sh
- +5 −0 test/spec.sh
| @@ -0,0 +1,34 @@ | ||
| #!/bin/bash | ||
| # | ||
| # From: | ||
| # | ||
| # https://lobste.rs/s/xhtim1/problems_with_shells_test_builtin_what | ||
| # http://alangrow.com/blog/shell-quirk-assign-from-heredoc | ||
| ### Blog Post Example | ||
| paths=`tr '\n' ':' | sed -e 's/:$//'`<<EOPATHS | ||
| /foo | ||
| /bar | ||
| /baz | ||
| EOPATHS | ||
| echo "$paths" | ||
| # stdout: /foo:/bar:/baz | ||
| ### Blog Post Example Fix | ||
| paths=`tr '\n' ':' | sed -e 's/:$//'<<EOPATHS | ||
| /foo | ||
| /bar | ||
| /baz | ||
| EOPATHS` | ||
| echo "$paths" | ||
| # stdout-json: "/foo\n/bar\n/baz\n" | ||
| ### Rewrite of Blog Post Example | ||
| paths=$(tr '\n' ':' | sed -e 's/:$//' <<EOPATHS | ||
| /foo | ||
| /bar | ||
| /baz | ||
| EOPATHS | ||
| ) | ||
| echo "$paths" | ||
| # stdout-json: "/foo\n/bar\n/baz\n" |
0 comments on commit
a79ebc8