mint-fortune fails to run upon terminal open

Bug #761446 reported by Matt Wilmott
82
This bug affects 17 people
Affects Status Importance Assigned to Milestone
Linux Mint
Invalid
Medium
Clement Lefebvre

Bug Description

Prints /usr/bin/mint-fortune: line 35: [: ==: unary operator expected

Cant determine which package it resides in or the binary version.

Running Linux Mint LXDE (Linux debian 2.6.32-5-amd64 #1 SMP Mon Mar 7 21:35:22 UTC 2011 x86_64 GNU/Linux). Updated at 3:30pm Friday 15th April 2011 AEST

Occurs when a new terminal window is open

Expect the fortune to be displayed instead of the error message seen above

Happens all the time

Fixed by editing line 35 of /usr/bin/mint-fortune to read

if [ "$showfortunes" == "true" ]; then

instead of

if [ $showfortunes == "true" ]; then

Also needed to add flag in gconf using

gconftool-2 --set /desktop/linuxmint/terminal/show_fortunes -t string true

This resolved the issue

Tags: mintsystem
Revision history for this message
Tim㋡ (tim.h.s) wrote :

I changed only line 35 to:
                       if [ $showfortunes="true" ]; then

Revision history for this message
Xavier Arosemena (xavier-iguanapolis) wrote :

me too. just deleted the spaces before and after the "=" sign, and leaved one "="sign. it worked

Revision history for this message
Cleocir (contato-cleocir) wrote :

SOLVED:

Edit file "/usr/bin/mint-fortune" and change the line 35 to:

    if [ "$showfortunes" == "" ]; then

Revision history for this message
Cleocir (contato-cleocir) wrote :

SOLVED:

Edit file "/usr/bin/mint-fortune" and change the line 35 to:

if [ "$showfortunes" == "" ]; then

Revision history for this message
Brett (breusshe) wrote :

I don't think the quotes around $showfortunes is necessary. I say this because I'm not using them in my solution and it works just fine. I altered the mint-fortune code to check for a null value in show_fortunes and set it to "true" if it is missing, then run show_fortune. I've tested this code by setting "show_fortunes" to the states of "", NULL (via --unset), true, and false:

"" or NULL: sets the gconf value of "show_fortunes" to true, runs show_fortune function
true or false: runs show_fortune function

Here is the modified code for mint-fortune:

#!/bin/bash

function show_fortune {
    RANGE=3
    number=$RANDOM
    let "number %= $RANGE"
    case $number in
        0)
            cow="moose"
            ;;
        1)
            cow="tux"
            ;;
        2)
            cow="koala"
            ;;
    esac

    RANGE=2
    number=$RANDOM
    let "number %= $RANGE"
    case $number in
        0)
            command="/usr/games/cowsay"
            ;;
        1)
            command="/usr/games/cowthink"
            ;;
    esac
    /usr/games/fortune | $command -f $cow
}

if [ -x "/usr/bin/gconftool-2" ]; then
    showfortunes=`gconftool-2 --get /desktop/linuxmint/terminal/show_fortunes 2>/dev/null`
    case $showfortunes in
        "true")
            show_fortune
            ;;
        "")
            gconftool-2 --set /desktop/linuxmint/terminal/show_fortunes --type string "true" 2>/dev/null
            show_fortune
            ;;
    esac
else
    show_fortune
fi

Revision history for this message
ScottMiller (stmiller) wrote :

Just remove the spacing around both sides the double equals sign.

Before:

if [ $showfortunes == "true" ]; then

After:

if [ $showfortunes=="true" ]; then

tags: added: mintsystem
Revision history for this message
ScottMiller (stmiller) wrote :

The package mintsystem is maintained by:

Clement Lefebvre clem [at] linuxmint [dot] com

Is someone able to assign this bug to him?

$dpkg -S mint-fortune
mintsystem: /usr/bin/mint-fortune

Justin Krehel (jkrehel)
Changed in linuxmint:
assignee: nobody → Clement Lefebvre (clementlefebvre)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Francis Earl (francis-earl) wrote :

I simply removed those if statements, and it also works fine now:

#!/bin/bash

function show_fortune {
    RANGE=3
    number=$RANDOM
    let "number %= $RANGE"
    case $number in
        0)
            cow="moose"
            ;;
        1)
            cow="tux"
            ;;
        2)
            cow="koala"
            ;;
    esac

    RANGE=2
    number=$RANDOM
    let "number %= $RANGE"
    case $number in
        0)
            command="/usr/games/cowsay"
            ;;
        1)
            command="/usr/games/cowthink"
            ;;
    esac
    /usr/games/fortune | $command -f $cow
}

 show_fortune

Since gconftool is going away, and likely not even used on various other spins, I am not sure why to keep this statement at all?

Revision history for this message
Francis Earl (francis-earl) wrote :

The whole point of mint-fortune is to create a function and run that function...

Why check to ensure the function was created after it was created? It seems unnecessarily complex... the various commands have to all be installed, but doesn't this package depend them?

To turn it off, simply have Desktop Settings comment the line in /etc/bash.bashrc if some users don't like the feature...

Revision history for this message
chemicalfan (mike-lumsden) wrote :

Does this bug apply to any of the currently supported releases (i.e. Maya, Nadia, Olivia, or Petra)? If not, this bug should be closed.

Revision history for this message
Arend Rietkerk (fliteshare) wrote : Re: [Bug 761446] Re: mint-fortune fails to run upon terminal open

Did you remove the: "Tomorrow you will die" fortune from the line-up as
well ?

On 2014-01-28 06:58, chemicalfan wrote:
> Does this bug apply to any of the currently supported releases (i.e.
> Maya, Nadia, Olivia, or Petra)? If not, this bug should be closed.
>

Revision history for this message
chemicalfan (mike-lumsden) wrote :

As no-one has updated this bug as to whether it is still valid, I am marking as invalid

Changed in linuxmint:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.