[Libreoffice] Test script patch review request (1)
tlillqvist at novell.com
Mon Jan 3 03:51:28 PST 2011
> cat /tmp/tabfile | sed 's/ / /' > /tmp/notabfile;
Sorry, but just replacing every TAB character with a fixed number (in this case, four) of SPACE characters is incorrect. To properly expand TAB characters, each TAB needs to be replaced with a variable number of SPACE characters, depending on which column the TAB is in.
For instance if you have a line:
(i.e. "foo", a TAB, and "bar"), the TAB should be replaced with just one SPACE. (Assuming the intended tab width is four columns, as it is in OOo/LO. Note that traditionally the tab width is eight columns.)
(Also, you would want to use the "g" modifier in the sed 's' command to replace every TAB on each line, not just the first.)
Anyway, the "expand" command is the right tool to expand tabs.
P.S. Your script can be written much simpler, no need to use "cat" so much:
while read fn </tmp/tabs.auto.filelist.txt; do
sed 's/ / /g' < $fn > /tmp/notabfile
mv /tmp/notabfile $fn
(Here still incorrectly using "sed" and not "expand".)
More information about the LibreOffice