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

Shell Functions example on ptpb.pw needs clarification #196

Open
superguest opened this issue Jun 6, 2017 · 1 comment
Open

Shell Functions example on ptpb.pw needs clarification #196

superguest opened this issue Jun 6, 2017 · 1 comment

Comments

@superguest
Copy link

pbx () { curl -sF "c=@${1:--}" -w "%{redirect_url}" 'https://ptpb.pw/?r=1' -o /dev/stderr | xsel -l /dev/null -b }

What does the 'r=1' do? Can you tell me where this is documented?
Also, are you sure you want to send the output to /dev/stderr when xsel is expecting input from the pipe?

Please direct me to a more appropriate (IRC?) support channel if this is not the place to ask.

Thanks!

@buhman
Copy link
Member

buhman commented Jun 6, 2017

Can you tell me where this is documented?

There 😄

Yeah, the query string arguments need documentation; when I wrote the api spec, I was mostly looking at the route table, which doesn't include those.

sure you want to send the output to /dev/stderr when xsel is expecting input from the pipe

Yes, xsel is using the output from curl's -w. The paste metadata is displayed on the terminal via stderr, while the paste url goes into the clipboard.

What does the r=1 do?

Normal POST responses are code 200. r=1 makes it a code 302 (redirect). 300 responses are required for curl's redirect_url to grab the location header (yet, location is provided all the time, even during non-300 responses).

Admittedly the single-character things make pb usage more obscure than it needs to be, but people wanted cute copy-paste things that fit into an 80-character terminal line.

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

No branches or pull requests

2 participants