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

Add documentation of how to use backslash escapes. #103

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

Conversation

tmccombs
Copy link
Collaborator

@tmccombs tmccombs commented Feb 8, 2022

See #102

@emersion
Copy link
Owner

emersion commented Feb 8, 2022

TBH this seems out of place for the man page.

@tmccombs
Copy link
Collaborator Author

tmccombs commented Feb 8, 2022

I agree with @subnut that the current text is a little misleading on how slurp handles \n, and it would probably be good to direct users on how to add newlines to a custom format string.

Do you have a better solution?

I suppose some other options are to always add a newline to the end of the output or to add a "%n" escape code to add a newline.

@columbarius
Copy link
Contributor

Alternative: Adding this at least to the README.md file, which already contains some examples?

@emersion
Copy link
Owner

My guess is that it doesn't really matter whether there's a newline or not, read(1) and getline(3) should still behave properly when there's no final newline. The fact that the default format includes a final newline is just a nicety to have slightly better output when the user manually invokes slurp (avoid having the shell prompt on the same line).

slurp's man page is not a good place to explain how to use a shell, especially when it's Bash specific.

I'd just change the man page to e.g.

The default format is "%x,%y %wx%h" followed by a newline.

Explicitly state that it ends with a newline to avoid suggesting that
"\n" is an accepted escape by slurp.

See: emersion#102
@tmccombs tmccombs force-pushed the escape-documentation branch from 4dd651b to 2fd80a8 Compare August 23, 2022 05:56
@tmccombs
Copy link
Collaborator Author

I've removed the shell specific note from the man page, and instead added an example to the README.

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.

3 participants