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 newline support for the format option #105

Open
Earnestly opened this issue Jul 14, 2018 · 4 comments
Open

Add newline support for the format option #105

Earnestly opened this issue Jul 14, 2018 · 4 comments

Comments

@Earnestly
Copy link

Earnestly commented Jul 14, 2018

Currently slop -f '...' doesn't produce a newline which makes it difficult to use in a slop | while read -r pipeline. I have tried adding \n to the -f format but it just prints a literal \n.

To workaround this issue I'm using { slop -f '...'; printf '\n' } | while read -r ...

(Another workaround is to simply absorb the input with a tool like awk)

@AloisMahdal
Copy link
Contributor

Another possible workaround s to include the newline (ie. not \n sequence) within the string; you can do it with Bash using this syntax: slop -f $'hey\n'.

But I agree it would be nice if slop could interpret the sequences by default.

@Earnestly
Copy link
Author

Earnestly commented Jul 14, 2018

The trouble with $'' is that it's not POSIX, as otherwise I could have used command substitution (<()) much like the examples in the manual demonstrate. Although $'' is slated for the next version of POSIX, so that's nice.

@ListeriaM
Copy link

A possible POSIX compliant workaround:

slop -f '...
' | while read -r ...

@Earnestly
Copy link
Author

For what it's worth, Issue 8 of POSIX will include the dollar quotes: https://gist.github.com/Earnestly/29deee4f18346da6630ed1df760f1590

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

3 participants