Skip to content
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

yanking without input #30

Closed
make-github-pseudonymous-again opened this issue May 4, 2016 · 6 comments
Closed

yanking without input #30

make-github-pseudonymous-again opened this issue May 4, 2016 · 6 comments

Comments

@make-github-pseudonymous-again

Yank does not exit directly when there's nothing in stdin. For example echo | yank waits for user input. Moreover, in this example, if I press Enter I get

yank: write: Bad address

@mptre
Copy link
Owner

mptre commented May 5, 2016

On Wed, May 04, 2016 at 02:50:51PM -0700, Aurélien Ooms wrote:

Yank does not exit directly when there's nothing in stdin. For example echo | yank waits for user input.

No news is good news, meaning if the input is empty or does not contain
any fields there will be no feedback. This is a common idiom among Unix
commands.

Moreover, in this example, if I press Enter I get

yank: write: Bad address

Which version are you using? Should be fixed in v0.6.3.

@make-github-pseudonymous-again
Copy link
Author

v0.6.2

@mptre
Copy link
Owner

mptre commented May 5, 2016

On Thu, May 05, 2016 at 02:37:36AM -0700, Aurélien Ooms wrote:

v0.6.2

Could you try v0.6.3 or greater and see if it resolves the error?

@make-github-pseudonymous-again
Copy link
Author

It doesn't crash in v0.6.4. However, I see the lack of (strong) distinction between echo | yank and { sleep 839283; echo 'bla'; } | yank as misleading for the user. The only difference I see in terminator is the blinking cursor.

@mptre
Copy link
Owner

mptre commented May 9, 2016

On Mon, May 09, 2016 at 06:32:23AM -0700, Aurélien Ooms wrote:

It doesn't crash in v0.6.4.

Glad to hear.

However, I see the lack of (strong) distinction between echo | yank and { sleep 839283; echo 'bla'; } | yank as misleading for the user. The only difference I see in terminator is the blinking cursor.

Your sleep example is tricky to detect since stdin remains open and will
until the echo command has finished. This would require one to use
poll/select with a timeout in order to detect "slow" input. If you want
to bypass yank when stdin is empty you could use wrapper command:

#/bin/sh

tmpfile=$(mktemp -t yank.XXXXXX)
trap "rm "$tmpfile"" EXIT

cat >"$tmpfile" # consume stdin

if [ -s "$tmpfile" ]
then
yank <"$tmpfile"
else
echo "stdin is empty, skipping yank..." 1>&2
exit 1
fi

@make-github-pseudonymous-again
Copy link
Author

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants