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

yank.sh updated for FreeBSD #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

RafalLukawiecki
Copy link

There is no ss natively on FreeBSD, but there is sockstat. This was making yank.sh fail. I have added another elif clause and a check for ss and sockstat presence, as yank.sh was failing. Also the usual replacement of #!/bin/bash with #!/usr/bin/env bash. Bear in mind that I use OSC52, and not xclip etc, as I do not use X11, only text mode, on remote servers. I have tested that elif clause using a different port to make sure it works, but I have not tested it with xclip. My grep -q test simply checks if there is a listening port, I am not sure if you need to test for anything more—I see you are using a more complex expression than mine with | tail -n +2 | wc -l, but I do not know why, as I cannot see what those two lines would contain.

Feel free to combine lines 26-29—I did not want to change your code too much.

Many thanks for creating your yank.sh script.

PS. I would keep this pending till tmux-online-status PR has merged.

@samoshkin
Copy link
Owner

@RafalLukawiecki

Given that ss is not present on FreeBSD. Maybe it makes sense to replace ss with regular netstat altogether to avoid 2 conditional clauses.

I guess, something simple like this would work:

elif [ -n "${copy_backend_remote_tunnel_port-}" ] && netstat -tln | grep -q ":$copy_backend_remote_tunnel_port"

Could you please check and tell if netstat -tln is present on FreeBSD?

@RafalLukawiecki
Copy link
Author

netstat does not take -t option on FreeBSD, and I am not sure what its function is—had a quick look on https://linux.die.net/man/8/netstat but I do not see that option there, either.

In any case, have a look here to see what we can do with netstat: https://www.freebsd.org/cgi/man.cgi?query=netstat

The output from netstat -ln looks like this, so the separator between the address and the port is just the final dot for IPv4 addresses. Feel free to ping me with sample invocations to try. I will be able to test more in-depth later tomorrow, as on a deadline at the moment, but I can do quick checks, like this one, without a problem.

screen shot 2017-12-12 at 18 15 29

@samoshkin
Copy link
Owner

Ok, I've prepared new revision using netstat instead of ss.

I haven't merged your pull request, because looks like it includes a bunch of irrelevant commits, so I just pick up your changes as a patch.

The commit is 95efd54, it's already in master. So you can just catch up with upstream's master and check it.

For Linux and FreeBSD I use netstat -4 -nl, on OSX netstat -f inet -nl. It's just about showing only INET sockets, and hide UNIX sockets and others.

Those small differences between platforms are very painful indeed - feels like I'm adopting webapp for IE6.

rkhaja added a commit to rkhaja/tmux-config that referenced this pull request Jul 21, 2023
…use C-a is used to beginning of terminal command.
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

Successfully merging this pull request may close these issues.

2 participants