brunophilipe / Cakebrew

Manage your Homebrew formulas with style using Cakebrew.
http://www.cakebrew.com
GNU General Public License v3.0
4.81k stars 255 forks source link

Problem with the new user shell approach... #59

Closed leoj3n closed 10 years ago

leoj3n commented 10 years ago

My setup echoes a fortune every time a new user shell is opened.

This gets picked up by Cakebrew. :panda_face:

cake

brunophilipe commented 10 years ago

I'm sorry but there's no way the parser can expect random text before the output data. It is a question of computability. The algorithm would require a lot of resources even for those who don't have such a thing in their terminal and I believe it is not worth it.

leoj3n commented 10 years ago

It's okay, I was able to fix the fortune script by changing it from

# Print a random, hopefully interesting, adage.
if (( $+commands[fortune] )); then
  fortune -a
  print
fi

to

# Print a random, hopefully interesting, adage.
if (( $+commands[fortune] )); then
  if [[ -t 0 || -t 1 ]]; then
    fortune -a
    print
  fi
fi

Which is probably best practice.

Still, -l seems cumbersome when garbage (from errors, a sysop message, or whatever else) may be printed at the beginning of a login shell.

brunophilipe commented 10 years ago

I haven't come across this kind of message before, but I would believe they would be sent through std_error instead of std_output, so Cakebrew would be safe from reading them since for formula listing it ignores std_error.