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

[QUESTION] Make sure command output has a newline at the end #183

Open
lobre opened this issue Oct 30, 2023 · 0 comments
Open

[QUESTION] Make sure command output has a newline at the end #183

lobre opened this issue Oct 30, 2023 · 0 comments

Comments

@lobre
Copy link

lobre commented Oct 30, 2023

I am trying to use rlwrap with sam -d for structural regular expressions in the taste of ed. However, sam sometimes outputs text that does not contain new lines. Here is an example.

$ cat input.txt
&Book: Programming Perl
&Author: Larry Wall&Author: Tom Christiansen&Author: Jon Orwant
&ISBN: 0-596-00027-8

And now I do this (note that sam is part of plan9port so should be invoked as 9 sam).

$ rlwrap 9 sam -d input.txt
 -. input.txt
2x/^&[^&]+
&Author: Larry Wall▌

Here, 2x/^&[^&]+ means "taking line 2 as input, extract text that starts at the beginning of the line with & and that ends before another &".

You can see that sam did not output a newline character ( represents the cursor position), because it extracted only the inline part, which is normal.

But I would still like rlwrap to always display a newline at the end of outputs.

I tried with a filter with this, but I still don't have a newline at the end.

rlwrap -z "makefilter awk '{print}'" 9 sam -d -a input.txt

Do you have guidance on how to do this? Thanks.

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

1 participant