Re: [AMBER] unable to compile amberTools12

From: Jason Swails <jason.swails.gmail.com>
Date: Wed, 26 Jun 2013 08:03:57 -0400

On Wed, Jun 26, 2013 at 7:37 AM, David A Case <case.biomaps.rutgers.edu>wrote:

>
> > flex -t cifparse.l | sed 's/yy/cifp/g' > lex.cif.c
> > /bin/sh: flex: command not found
>
> [snip]
>
>
> [Aside for developers: why didn't the above failure stop the build at that
> point? Does it have something to do with the pipe command?]
>

Sort of. The flex command runs and produces output (but errors, obviously,
so nothing is printed to stdout). Sed then takes the the flex stdout,
runs, and substitutes a pattern on an empty string. Sed ran successfully,
and it ran last, so the return value of the whole statement is 0.

To demonstrate:

swails.Batman ~ $ flex2 nothing | sed 's/yy/cifp/g' > blah
-bash: flex2: command not found
swails.Batman ~ $ echo $?
0
swails.Batman ~ $ cat blah
swails.Batman ~ $ flex2 nothing
-bash: flex2: command not found
swails.Batman ~ $ echo $?
127

However, it appears to be a /bin/sh thing. Using tcsh, the return value
is an error:

(Batman:~) swails% flex2 nothing | sed 's/yy/cifp/g' > blah
flex2: Command not found.
(Batman:~) swails% echo $?
1
(Batman:~) swails% flex2 nothing
flex2: Command not found.
(Batman:~) swails% echo $?
1
(Batman:~) swails% echo $?
0

According to a SO thread, there's a way to trigger bash to stop at the
first failed command in a pipeline and return that value (which appears to
be what tcsh does by default).
http://stackoverflow.com/questions/1550933/catching-error-codes-in-a-shell-pipe

I'm not sure how much of that is POSIX standard, though, so I don't know
that we could assume it works for all /bin/sh's.

All the best,
Jason

-- 
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
352-392-4032
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Wed Jun 26 2013 - 05:30:02 PDT
Custom Search