#10339: Simplify spkg/pipestatus
------------------------------+---------------------------------------------
Reporter: jdemeyer | Owner: GeorgSWeber
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.6.1
Component: build | Keywords: pipestatus Makefile
Author: Jeroen Demeyer | Upstream: N/A
Reviewer: Leif Leonhardy | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Comment(by leif):
Replying to [comment:24 jdemeyer]:
> Replying to [comment:23 leif]:
> > Using `eval` twice still behaves different to what you get directly on
the command line; we could instead use:
>
> I disagree.
Well, certainly not on what one gets directly at the shell prompt.
> Personally, I wouldn't expect `pipestatus` to behave in a way that the
first argument influences the second. For me, the command line arguments
to `pipestatus` are like "blocks" and should not be split. In other
words, I expect
{{{
pipestatus "A && B" "C"
}}}
> to behave like
{{{
(A && B) | (C)
}}}
And I would expect `pipestatus cmd1 cmd2` to behave as what it is intended
to replace (for the only reason that the direct syntax isn't supported by
dead old bashs on user-friendly OSs):
{{{
$ set -o pipefail; cmd 1 | cmd2
}}}
We here have simple textual substitution (or term rewriting like in
macros):
{{{
pipestatus = lambda cmd1. cmd2: cmd1 | cmd2
}}}
That's not eager evaluation / call by value, like (analogously)
{{{pipestatus `eval cmd1` `eval cmd2`}}}, or what one would expect from
true functions. Of course I would
{{{
#!C
#define mul(a,b) ((a)*(b)) /* and not (a*b), which might give contra-
intuitive results */
}}}
but that's a different story (and you certainly know the pitfalls when
passing things like `n++` to macros rather than [inline] functions).
In a shell, with a `|` operator, I would expect exactly what the shell
(and especially `make`, in our application domain) usually does, namely
simple text substitution (and concatenation without bracketing), for
perhaps later evaluation. If I want or need parentheses here, I pass them.
And as a side-effect, we get `bash` into the `make` receipt. Rather than
writing
{{{
#!make
target: prereq
bash -c "cmd1" ; pipestatus "cmd2" "cmd3" ; bash -c "cmd4"
}}}
we can simply do
{{{
#!make
target: prereq
pipestatus "cmd1 ; cmd2" "cmd3 ; cmd4"
}}}
with the advantage of having the ability to e.g, set environment variables
in the first command that take effect in the latter.
Ok, you could also write
{{{
#!make
target: prereq
bash -c "cmd1 ; pipestatus cmd2 cmd3 ; cmd4"
}}}
but then you again get into trouble with quoting.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10339#comment:27>
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.