Should grep append new lines on its output?
e.g.
echo -n abc | grep abc
This command will print "abc" followed by NewLine in Bash. FluidShell also behaved the same way in previous builds, but no more in beta-38 . This might be caused by the changes on #7586.
Note that matched content already ends with new line ( e.g. echo abc | grep abc
), the \grep command shouldn't append additional new line. Here the latest builds behave as expected.
Made change to add newline back to a matched line if it is not presented at the end so that fluid \grep would behave like bash grep in most cases.
Fluid \grep should produce exactly the same result as bash grep does on text files but not binary files. We don't have a good way to determine whether a file is a binary file or not, hence fluid command below:
prompt$ \grep "" binary-file > tmp.out
would create tmp.out with exactly same contents as binary-file has plus a newline appended at the end; while executing same command in bash
prompt$ grep "" binary-file
produces
Binary file binary-file matches.
Issue #7607 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build trunk/29392 |
No time estimate |
1 issue link |
is a duplicate of #7626
Issue #7626No new line when pipelining \echo -n with \grep |
Made change to add newline back to a matched line if it is not presented at the end so that fluid \grep would behave like bash grep in most cases.
Fluid \grep should produce exactly the same result as bash grep does on text files but not binary files. We don't have a good way to determine whether a file is a binary file or not, hence fluid command below:
prompt$ \grep "" binary-file > tmp.out
would create tmp.out with exactly same contents as binary-file has plus a newline appended at the end; while executing same command in bash
prompt$ grep "" binary-file
produces
Binary file binary-file matches.