Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Parser: fish fails to traverse pipes across newlines. #1285
I believe in any other shell that uses the pipeline syntax fish inherits, it is allowed to break the statement at the pipe itself. That is, if
echo foo | cat - | # Tab space comments. cat
But in fish, the newline must be escaped:
The other ones are the boolean operators.
Can be used to order a non-branching logical secuence quite effectively.
#!/usr/bin/env sh cat "$0"; sleep 2; echo; echo [ 1 -eq 0 ] && [ 0 -eq 1 ] && [ a = b ] && [ 1 -eq 10 ] && [ a = b ] && return 42 || [ 0 -lt 10 ] && [ a = a ] && [ 2 -eq 2 ] && [ 1 -eq 1 ] && [ a = a ] && we=2 && too=to #|/#/#*/|/##* tea=to && test 2 != $we ||#/####/ echo we $we sit to have tea $tea | ##| cat - | tee && #\ echo now we $tea | cat - && #\ #\#\*##*> echo $too who\? $too we||:; echo ❦ >&2
Same error in fish though, yep.
Oops. Right, duh. @zanchey darn you distracting me! Ha.
Correct me if I'm wrong x, but to be specific, they are (builtin) functions, which conditionally execute their arguments based of the return value of the prior statement.
... so anyway, just the issue in the title. Pipes.
... Interesting. It seems (from an analytic standpoint) it would work exactly the same as a function. But I'm sure implementation-wise its the way it is for some reason.
I can't see any logical reason why any function for which one or more argument is required, and further arguments are still needed, needs to be treated any differently than a block that has not seen its end statement. That is, to require not just whitespace to separate arguments, but literally to require code point 20 (or 8, tab), and allow multiple runs of these, but disallow a newline. Its all whitespace. For example,
is invalid on the left, but valid of the right. It's not like there's any ambiguity here — there's no possibility of it "getting it wrong" by completing the statement too soon. In each case if the correct number of arguments are not given, you get an error.
Also I just turned up another bug I think in testing that — while I can still
We should consider the experience of novice users. I remember in bash I would often do something (like paste a string containing a backtick or other sigil) that would get me "lost" in a sequence of '>' prompts, where I had to know to ctrl-C out of it.
Good catch on the /bin/[ bug!
@ridiculousfish no contention there — same thing happened to me — but I actually had an analogous experience with fish as well, something to this effect:
~> if true _ # < Um, where am I? What's going on here?
~> if true echo 1 _ # < Ok I get it now.
The next time, I remember there's some type of automatic handling of interactive multiline statements, but I forgot that it's
~> if true
and I get:
~> if fish: Expected a command name, got token of type 'End of command' if ^ ~>
and so I guess (maybe I'm just weird) I find (found) this to be a quite confusing distinction.