Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#3374 closed task (fixed)

LibreOffice for loop fails to create launcher scripts

Reported by: Arthur Radley Owned by: bdubbs@…
Priority: normal Milestone:
Component: BOOK Version: SVN
Severity: normal Keywords:
Cc:

Description

For me anyway, the for loop immediately following the make install command fails with a bash error causing the whole block of commands not to complete.

echo "#!/bin/bash
bash: !/bin/bash: event not found

I was copying and pasting the whole block of commands from the book directly to a bash shell command prompt like I often do. But maybe there is something about my environment causing this particular echo line not work as expected for me. Anyway, I created these launcher scripts sort of manually...

cat > /usr/bin/base << "EOF"
#!/bin/bash
exec /usr/lib/libreoffice/program/soffice --nologo --base "${@}"
EOF
cat > /usr/bin/calc << "EOF"
#!/bin/bash
exec /usr/lib/libreoffice/program/soffice --nologo --calc "${@}"
EOF
cat > /usr/bin/draw << "EOF"
#!/bin/bash
exec /usr/lib/libreoffice/program/soffice --nologo --draw "${@}"
EOF
cat > /usr/bin/impress << "EOF"
#!/bin/bash
exec /usr/lib/libreoffice/program/soffice --nologo --impress "${@}"
EOF
cat > /usr/bin/math << "EOF"
#!/bin/bash
exec /usr/lib/libreoffice/program/soffice --nologo --math "${@}"
EOF
cat > /usr/bin/writer << "EOF"
#!/bin/bash
exec /usr/lib/libreoffice/program/soffice --nologo --writer "${@}"
EOF

Maybe someone can tell me why the book's commands might be doing this only for me, or maybe someone can think of a better way to generate these six scripts in the book.

Change History (12)

comment:1 by Arthur Radley, 12 years ago

Okay. Written this way, the for loop creates the six LibreOffice startup scripts for me...

for program in base calc draw impress math writer
do
  echo '#!/bin/bash' > /usr/bin/${program}
  echo "exec /usr/lib/libreoffice/program/soffice --nologo --${program} \"\${@}\"" >> /usr/bin/${program}
  chmod 755 /usr/bin/${program}
done

The difference from the current book's version is it echoes in the bash shebang using single quotes in a separate step, and then appends the exec line as a second step with double quotes. I don't know how pretty this is, but it worked and was better than manually creating the six scripts.

comment:2 by Wayne Blaszczyk, 12 years ago

Do you have the histchars variable set?

Try set +o histexpand

in reply to:  2 comment:3 by Arthur Radley, 12 years ago

Replying to wblaszcz:

Do you have the histchars variable set?

Try set +o histexpand

Yes, histexpand was on. Turning it off allowed the commands in the book to run as expected. Thanks. Even though I am not exactly a naif at things Linux, I didn't know about this. And I have never before encountered this particular situation. Anyway, a few minutes with the appropriate section of the bash man page revealed all to me. And according to that reference, histexpand is enabled by default for interactive shells. Okay fine. Onward to the next mystery.

comment:4 by Arthur Radley, 12 years ago

After playing around with this matter some more, I guess I still don't understand why the book's commands to create the LibreOffice startup scripts are written as they are.

According to man bash, histexpand is enabled by default (as it was for me). And I discovered through playing around with it that disabling histexpand with merely a single bash set command does not persist to the next bash shell. Apparently, permanently disabling histexpand requires the set +o histexpand command in .bashrc (or something equivalent). I really doubt many people do that since I have never seen such a thing discussed or suggested in the fifteen or so years that I have been using Linux. I mean, I'm sure everyone else in the world knew about this, but histexpand and I have somehow managed never to cross paths.

I'm just an ordinary Linux user, but am I wrong to expect other people to encounter the same problem that I did? Shouldn't set +o expand be added to the book's commands?

comment:5 by Arthur Radley, 12 years ago

I meant to ask... Shouldn't set +o histexpand be added to the book's commands?

comment:6 by bdubbs@…, 12 years ago

Try this:

SOFFICE=/usr/lib/libreoffice/program/soffice  &&
for p in base calc draw impress math writer
do
  echo '#!/bin/bash' > /usr/bin/${p}
  echo "exec $SOFFICE --nologo --${p} \"\${@}\"" >> /usr/bin/${p}
done &&
unset SOFFICE

The SOFFICE variable is just to shorten things up and make clear.

It's basically what is in comment 1, but with some clarification. I suspect the reason this problem came up was because it was checked from a script but not from cut/paste.

comment:7 by Arthur Radley, 12 years ago

I did try it, and it does the job. It's easy on the eyes, too. I recommend that block should go into the book. And if that happens, include the chmod line in the for loop.

And thank you all for effort that went into putting LibreOffice in the book. And thank you to The Document Foundation, I guess, for LibreOffice in the first place. For something so comparatively easy to build and install, it makes my BLFS system rival any of my distros. I only have one left now (Arch), and I only use it to backup my BLFS system on Saturdays.

comment:8 by bdubbs@…, 12 years ago

Owner: changed from blfs-book@… to bdubbs@…
Status: newassigned

comment:9 by bdubbs@…, 12 years ago

Resolution: fixed
Status: assignedclosed

Fixed at revision 10229.

in reply to:  6 comment:10 by Fernando de Oliveira, 12 years ago

Replying to bdubbs@…:

[...]

It's basically what is in comment 1, but with some clarification. I suspect the reason this problem came up was because it was checked from a script but not from cut/paste.

Did not know how to solve this issue, because I use symlinks, instead of the scripts.

Perhaps, Andy decided for scripts to get rid of the splash (logo) screen.

Either with symlinks or dropping the "--nologo" in the scripts, the splash screen not just displays the logo, but also informs that the application is starting. IMHO, this is useful.

in reply to:  6 comment:11 by andy@…, 12 years ago

Replying to bdubbs@…:

I suspect the reason this problem came up was because it was checked from a script but not from cut/paste.

I did check it with copy and pasting but I had forgotten that I have in ~/.bashrc:

histchars=

comment:12 by bdubbs@…, 10 years ago

Milestone: current

Milestone current deleted

Note: See TracTickets for help on using tickets.