ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
553 stars 52 forks source link

Shell Functions example on ptpb.pw needs clarification #196

Open superguest opened 7 years ago

superguest commented 7 years ago

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 commented 7 years ago

Can you tell me where this is documented?

There :smile:

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.