Permalink
Browse files

Testing a here doc + command sub example from lobste.rs / blog post.

  • Loading branch information...
Andy Chu
Andy Chu committed Sep 2, 2017
1 parent 5ca7bac commit a79ebc8437781b8edb8fd8ad03276fc6255af1f3
Showing with 42 additions and 0 deletions.
  1. +34 −0 spec/blog-other1.test.sh
  2. +3 −0 test/spec-runner.sh
  3. +5 −0 test/spec.sh
View
@@ -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"
View
@@ -31,6 +31,9 @@ _spec-manifest() {
# This was meant for ANTLR.
if (name == "shell-grammar") next;
# Just a demo
if (name == "blog-other1") next;
print name
}
'
View
@@ -190,6 +190,11 @@ blog2() {
${REF_SHELLS[@]} $ZSH $OSH "$@"
}
blog-other1() {
sh-spec spec/blog-other1.test.sh \
${REF_SHELLS[@]} $ZSH $OSH "$@"
}
comments() {
sh-spec spec/comments.test.sh ${REF_SHELLS[@]} $OSH "$@"
}

0 comments on commit a79ebc8

Please sign in to comment.