#10339: Simplify spkg/pipestatus
------------------------+---------------------------------------------------
Reporter: jdemeyer | Owner: GeorgSWeber
Type: defect | Status: new
Priority: major | Milestone: sage-4.6.1
Component: build | Keywords: pipestatus Makefile
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------+---------------------------------------------------
Comment(by leif):
Replying to [ticket:10339 jdemeyer]:
> Consider a command
{{{
#!sh
pipestatus "A && B" "C"
}}}
Someone reading the "documentation":
{{{
if [ -z "$1" ]; then
echo "Run two commands in a pipeline 'CMD1 | CMD2' and exit"
echo "with the exit status of CMD1, *not* that of CMD2."
echo "$0 cmd1 cmd2"
exit
fi
}}}
would perhaps do:
{{{
#!sh
pipestatus "(A && B)" "C"
}}}
but we can add the parentheses in `pipestatus` to get the same behavior in
both cases:
{{{
#!diff
--- pipestatus.orig 2010-07-22 10:54:43.000000000 +0200
+++ pipestatus 2010-11-26 16:14:37.000000000 +0100
@@ -16,7 +16,8 @@
if [ $VER -gt 2 ]; then
# Use bash 3.0's pipefail option.
- (set -o pipefail; eval "$1 | $2")
+ set -o pipefail
+ eval "($1) | $2"
exit $?
else
# Use redirection. Adapted from the comp.unix.shell FAQ. See
}}}
Btw, if we change pipestatus, we should also `test $# -eq 2` and give an
error otherwise. Such a change was previously rejected just because
someone didn't want to touch `pipestatus` or `spkg/install` again.
> Alternative 1 (for new versions of bash) does {{{A && (B | C)}}} while
alternative 2 (for old versions of bash) does {{{(A && B) | C}}}.
The patch above fixes that, though it's IMHO a minor issue, because one
can easily make the call to `pipestatus` unambiguous.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10339#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.