-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
waiting for input
contaminates buku output.
#513
Comments
related to this issue qutebrowser/qutebrowser#2491 which come from this #447 |
If you delete It turns out that if fzf calls My script doesn't call |
I mapped |
qutebrowser/qutebrowser#2491 (comment) pointed out that not calling qutebrowser worked around #447 worked around I think deleting If I wanted to read command line options from standard input, I can easily write a shell script for that. |
I see the following work if 1 ~/GitHub/buku$ cat input
www.google.com
www.yahoo.com
1 ~/GitHub/buku$ cat script
#!/usr/bin/env sh
while IFS= read -r url; do
./buku -a $url
done < input
1 ~/GitHub/buku$ xargs -I {} -a input ./buku -a {}
481. Google
...
482. Yahoo India | News, Finance, Cricket, Lifestyle and Entertainment
...
1 ~/GitHub/buku$ ./buku -d 481-482
...
1 ~/GitHub/buku$ ./script
481. Google
...
482. Yahoo India | News, Finance, Cricket, Lifestyle and Entertainment
... What don't work are: 1 ~/GitHub/buku$ cat | ./buku -a
usage: buku [OPTIONS] [KEYWORD [KEYWORD ...]]
buku: error: argument -a/--add: expected at least one argument
// WAITS HERE
1 ~/GitHub/buku$ cat input | ./buku -a
usage: buku [OPTIONS] [KEYWORD [KEYWORD ...]]
buku: error: argument -a/--add: expected at least one argument
1 ~/GitHub/buku$ echo "www.google.com" | ./buku -a
usage: buku [OPTIONS] [KEYWORD [KEYWORD ...]]
buku: error: argument -a/--add: expected at least one argument How does your script call The problem this isn't so straight is - many utilities use However, I don't see a reason to wait for data if no arguments are passed. Can you try the following patch? diff --git a/buku b/buku
index 38949fd..1d9a3e0 100755
--- a/buku
+++ b/buku
@@ -5043,10 +5043,11 @@ def main():
pipeargs = []
colorstr_env = os.getenv('BUKU_COLORS')
- try:
- piped_input(sys.argv, pipeargs)
- except KeyboardInterrupt:
- pass
+ if len(sys.argv) > 1:
+ try:
+ piped_input(sys.argv, pipeargs)
+ except KeyboardInterrupt:
+ pass
# If piped input, set argument vector
if pipeargs: Note that we treat only-positional-argument implicitly as The following work with this: $ echo "hello" | ./buku -s
$ cat input | ./buku -a
waiting for input
481. Google
... |
Reading command line arguments from standard input is an undocumented feature. Only documented public contracts should be preserved for some time. Various projects explicitly tell people to expect undocumented features to be broken at any point. I discovered this feature only after reading source code. I read the source code because Why would you expect people to rely on undocumented esoteric features? Just remove it. Retaining the feature already caused three people to file an issue. It wasted man hours. It can be implemented by a simple shell script which is usually written by a person who knows a system from inside out.
|
Usually I grep the code of the utilities involved when I try something new and see an error message. I can understand it was unexpected and may get overwhelming when faced the first few times.
Sorry, I don't like your tone and it's not really the time I would want to engage in a war of words on a mundane python script. You have to understand that I don't owe you or anyone else anything for using my utility. But this thread doesn't read like a discussion anymore. It's more of an accusation now. |
I have been on a high-pressure project. While on a high-pressure project, I had to deal with this. Sorry for being angry at you. |
It should be possible to keep piped_input and fix this issue, too. It's going to be your choice to do nothing out of anger or fix the issue which someone else who's not me will encounter someday. |
I don't have any of those. These kind of discussions are cheap and lack maturity, that's all. I prefer to avoid these. Not exactly a great start to a bright Sunday morning one should spend with family. Coming to the tool issue, How about adding an option to explicitly instruct buku to skip reading stdin? We can mandate it to be the first argument, if used. That way if we find a valid |
That is okay, but it is also feasible to add an option to read standard input as command line options. I don't have a strong opnion about either option, but the thing about standard input shall be documented properly if you choose to add an option to ignore standard input instead of an option to honor standard input. An option to treat standard input as command line arguments may minimize surprises experienced by new users. But, you can argue otherwise. |
I would say we should use the option to explicitly say - do not wait for stdin. Probably And we should update the message to:
|
Please update your PR accordingly. |
No need to add the option to auto-completion scripts as it does not apply to manual input from a tty.
For the record (I couldn't remember this earlier), we do have a common use-case for reading from a non-tty: https://github.com/jarun/buku/wiki/System-integration#bookmark-from-anywhere |
My programs parse the output of buku. The programs are called by fzf on terminal emulator.
However, the output is often contaminated with
waiting for input\n
at the beginning.fzf needs to reload the list of bookmarks by calling a script that updates buku cache by calling
buku -p -f 5
.If fzf called the script after calling
buku -w number
on another terminal emulator,waiting for input\n
contaminates the output and kills the script.If fzf called the script without calling
buku -w number
,waiting for input\n
doesn't contaminate the output.Is
print('waiting for input')
really absolutely necessary for correct functionality?The text was updated successfully, but these errors were encountered: