-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple scripts failing with random "dgsh: timeout for negotiation" #95
Comments
Regarding the one-liner, this looks like an error in the dgsh grammar, because Regarding the erratic behavior, maybe a state variable isn't initialized properly. Please try isolating it in a small script with a couple of multipipe invocations. |
So it wasn't a misunderstanding on my part concerning the correct syntax? Just checking if I understood correctly. I just tried to replicate the aforementioned behaviour, so I did the following: $ dgsh Of course with the non-existant files I also expected errors, but are all the "timeout for negotiation" normal here? |
The Regarding the small script, I meant one to replicate the erratic behavior through a script, rather than interactively. |
@dspinellis Ok. Let me rephrase: I was talking about the script I demonstrated in the gist, the one with the nested multipipe block. Would like me to try and reproduce the bug using a script without a nested multipipe block, just with a single multipipe block? Would that be in line with your request for a small(er) script? |
Don't worry, I think I have minimal examples for everything. Please stand by. |
Grammar problem# Fails
{{ {{ echo hello ; }} | cat ; echo world ; }} | cat
# Equivalent multi-line works
{{
{{ echo hello ; }} |
cat
echo world
}} |
cat
# Equivalent shell construct works
{ { echo hello ; } | cat ; echo world ; } | cat Interactive use problemPasting the following into the shell in one go gives a negotiation problem error. Pasting it in two chunks, works fine. {{ echo hello ; }} | cat
echo world Here is a session:
|
BTW @dspinellis @mfragkoulis I am deeply thankful both for the tool and the work you are putting into it. |
Thank you @trantor for helping us make dgsh a reliable tool. |
Thank you @trantor for your kind words! Please note that we have not up to now used dgsh interactively, which may explain the teething problems of instability you're experiencing. On the other hand, we've used dgsh extensively with scripts where it has proven quite reliable, even to the point of meta-programming (see the dgsh-parallel script). We'd be very interested to see how you use dgsh, and perhaps also add some part of your work in the examples section. |
@mfragkoulis 👍 |
Fix bug in concentrator that manifests when handling ERROR state Fix issue #95
@trantor does the fix resolve the interactive use problem? |
@mfragkoulis Afraid not. Just built dgsh from scratch and the behaviour is exactly the same with the commands and script in the gist. :( |
Hm, I'll take a look at the gist. {{ echo hello ; }} | cat
echo world |
@mfragkoulis That works fine |
Ensure that dgsh syntax, that is '{{' and '}}', is always treated as reserved words Issue #95
@trantor thanks for the heads up! |
@mfragkoulis This is the grammar problem. |
@mfragkoulis Sorry I hadn't seen your last commit. Checking it out now. |
$ cat test1 | tee | {{ {{ cat test2 & cat & }} | grep -f - & cat & }} | cat Strange thing below. $ ./dgsh-sample Rebuilding it from scratch again to check for leftovers of the previous build. |
Apparently now the command line and the script give the same output. a as output most of the time but not all the time, just as seen in the previous comment. |
Running strace on grep shows me that grep's standard output isn't properly connected.
Furthermore, the trailing cat's debug output shows that it got assigned only one input channel
|
@dspinellis that's true. @trantor do you get the expected behavior now? Note that there are limitations to the functionality we can achieve by modifying the |
@mfragkoulis grep should be silent (not attempt to write) or issue an error in the above case. I have mixed feelings regarding the re-implementation of grep. Wrapping the invocation of multiple grep commands doesn't offer much in comparison to what you can already write by hand. I proposed writing in C a bare-bones version of grep that would loop reading lines, invoking regex_match and outputting in different channels (depending on its arguments)
However, although this is elegant, I see the following issues.
Note that the last two are capabilities we already use. |
@mfragkoulis I don't get the "grep: write error" anymore adding @dspinellis About the possible replacement, no "fast" fixed string search on no fixed string search at all? What about the other three modes? Practically speaking fixed string search is something I use quite a lot. |
@trantor We're discussing to find the best approach. Nothing is yet cast in stone. We were thinking that
What do you mean by "What about the other three modes?" |
@dspinellis Basic Regular Expressions match , Extended Regular Expressions match and PCRE match. For GNU grep obviously. |
I was thinking of a simple loop calling |
@dspinellis I for instance use rather heavily the PCRE match function (grep --perl-regexp|-P). Look-aheads, Look-behinds etc. are vital features afaiac. |
@dspinellis dgsh-grep -c -v pattern file where the produced script or hand-written form is: {{
grep -c pattern file
grep -v pattern file
}}
# or
{{ grep -c pattern file ; grep -v pattern file ; }} It seems to me that the benefit of dgsh-parallel -n 2 'echo C{}' where the produced script or hand-written form is: {{
echo C1
echo C2
}}
# or
{{ echo C1 ; echo C2 ; }} Here is a more complicated example of dgsh-grep --recursive --ignore-case --color --context=2 -c -v -l -L pattern dir where the produced script or hand-written form is: {{
grep --recursive --ignore-case --color --context=2 -c pattern dir
grep --recursive --ignore-case --color --context=2 -v pattern dir
grep --recursive --ignore-case --color --context=2 -l pattern dir
grep --recursive --ignore-case --color --context=2 -L pattern dir
}} Here is a more complicated example of dgsh-parallel -n 5 "tr -s ' \t\n\r\f' '\n' | sort -S 512M | uniq -c" where the produced script or hand-written form is: {{
tr -s ' \t\n\r\f' '\n' | sort -S 512M | uniq -c
tr -s ' \t\n\r\f' '\n' | sort -S 512M | uniq -c
tr -s ' \t\n\r\f' '\n' | sort -S 512M | uniq -c
tr -s ' \t\n\r\f' '\n' | sort -S 512M | uniq -c
tr -s ' \t\n\r\f' '\n' | sort -S 512M | uniq -c
}} An additional advantage of I am hesitant regarding the bare-bones version of
|
Thanks @mfragkoulis for the link and the example. I'll try to debug what the completion actually does (programmable completion should be active) and open a new issue on that. About dgsh-grep, If I understand correctly the selection of how many output channels appear and what's in them would follow the order of a select number of grep options. But what if I wanted to translate a match with multiple patterns and non-simple combinations? |
@mfragkoulis I think it would be difficult to get the semantics of the grep script correct and understandable. In contrast, dgsh-parallel just repeats N times the same command. I agree that there is currently no demonstrated need for a C implementation. Therefore, I suggest, following POLA, to just fix the existing grep implementation so that it will output lines by default, mirroring the operation of the unmodified version.
|
Is it OK to close this issue? |
Hello.
I am trying out dgsh using simple scripts, but I am encountering erratic behaviour which I am unable to explain.
What I've noticed is that after entering dgsh interactively, and executing dgsh scripts after a while I get multiple "dgsh: timeout for negotiation" lines with no result.
Then I leave the shell, I re-enter it and run the very same scripts and they work (sort of).
Hard to replicate unfortunately.
On top of that I am running what to me are simple scripts, but I get strange errors there too.
This gist outlines them.
Sorry to combine multiple problems in a single issue, but I am unable to sort them out precisely.
My system is a Ubuntu 16.04 64bit, and I just built the latest version of dgsh (HEAD at 13a52b0 ).
The text was updated successfully, but these errors were encountered: