| View previous topic :: View next topic |
| Author |
Message |
RealNC Tux's lil' helper


Joined: 13 Apr 2008 Posts: 147
|
Posted: Sun Apr 13, 2008 2:55 am Post subject: here-documents in ebuild |
|
|
Ahoy.
I'm writing an ebuild that has a src_test() and one of the tests needs to be a here-document (command <<- EOF). But I need to do a 'die "Failed"' call if the test fails and I can't get the syntax right. Imagine this:
| Code: | src_test() {
./frob <<- EOF || die "frob failed"
foo
bar
EOF
}
|
It passes 'ebuild digest' but fails on emerge. What's the right syntax? Here's the error message:
| Code: | [...]temp/environment: line 2329: syntax error near unexpected token `||'
[...]/temp/environment: line 2329: ` || die "frob failed";'
*
* Call stack:
* ebuild.sh, line 1641: Called die
* The specific snippet of code:
* preprocess_ebuild_env || \
* die "error processing environment"
* The die message:
* error processing environment |
|
|
| Back to top |
|
 |
Hu Watchman

Joined: 06 Mar 2007 Posts: 6828
|
Posted: Sun Apr 13, 2008 3:40 am Post subject: |
|
|
Would it be acceptable to call die separately afterward? This may confuse the automatic backtrace logic in die, but should produce the correct behavior: | Code: |
./frob <<- EOF
foo
bar
EOF
[ $? -eq 0 ] || die "frob failed"
|
|
|
| Back to top |
|
 |
RealNC Tux's lil' helper


Joined: 13 Apr 2008 Posts: 147
|
Posted: Sun Apr 13, 2008 5:55 pm Post subject: |
|
|
| It works OK that way. I was just wondering if it needs a syntax I'm missing. I can't find one, so I'll use your suggestion. |
|
| Back to top |
|
 |
RealNC Tux's lil' helper


Joined: 13 Apr 2008 Posts: 147
|
Posted: Sun Apr 13, 2008 8:33 pm Post subject: |
|
|
Damn. More bugs. Example:
| Code: |
src_test() {
./frob <<- EOF
foo
bar
baz
EOF
}
|
only "foo" gets passed to ./frob. bar and baz (and everything else up to EOF) are totally ignored and have no effect. |
|
| Back to top |
|
 |
Hu Watchman

Joined: 06 Mar 2007 Posts: 6828
|
Posted: Sun Apr 13, 2008 8:35 pm Post subject: |
|
|
| I tried the same with /usr/bin/cat instead of ./frob and I get the expected output. Are you sure frob is written to accept multiline input? |
|
| Back to top |
|
 |
RealNC Tux's lil' helper


Joined: 13 Apr 2008 Posts: 147
|
Posted: Sun Apr 13, 2008 9:01 pm Post subject: |
|
|
Yes, it's no problem with frob. See, this normal script (call it tst.sh):
| Code: | #! /bin/sh
/frob <<- EOF
foo
bar
baz
EOF |
Produces the correct results when run. The bugs appear only when trying to do this in an ebuild. |
|
| Back to top |
|
 |
RealNC Tux's lil' helper


Joined: 13 Apr 2008 Posts: 147
|
Posted: Mon Apr 14, 2008 12:25 am Post subject: |
|
|
Oops, it turns out it WAS a problem with frob
Sorry for the confusion. It works OK. |
|
| Back to top |
|
 |
|