LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   BASH: Error on "silly" script idea. (https://www.linuxquestions.org/questions/linux-newbie-8/bash-error-on-silly-script-idea-869866/)

SilversleevesX 03-20-2011 09:19 PM

BASH: Error on "silly" script idea.
 
The error that appears is "unexpected EOF," and as I've made further edits, I've not been able to find it. I believe there's another kind of error here, but BASH might not have a more accurate way of describing it, so "unexpected EOF" is the message I'm getting instead.

Here's the script as currently written:
Code:

#!/bin/bash
#historyswitch-
#Changes the state of histexpand to off when on and vice-versa
function on2off(){
echo -e "History expansion is currently ON."
echo -e "You cant use exclamation points in strings."
echo -e "Do you want me to turn it OFF? {y/n}"
read yesno
if [[ $1yesno != "n" ]]; then
        set +H
        echo -e "History expansion is now OFF.
        echo -e "Happy emphasizing."
else
        echo -e "No action taken."
fi
}
function off2on(){
echo -e "History expansion is currently OFF."
echo -e "You cant use carats to edit previous commands."
echo -e "Do you want me to turn it ON? {y/n}"
read yesno
if [[ $2yesno != "n" ]]; then
        set -H
        echo -e "History expansion is now ON."
        echo -e "Enjoy the edits."
fi
if [[ $2yesno = "n" ]]; then
        echo -e "No action taken."
fi
}
c=$(set -o | grep histexpand)
if [[ $c == *on* ]]; then
        on2off
else
        off2on
fi

A silly idea, I know. But I often go for weeks without seeing a single manual page or other reference, and these scripts and aliases serve as excellent shortcuts to command & option syntax I know I'll forget. (I know because I already have forgotten often enough.)

Hope someone can help soon.

BZT

anishkumarv 03-20-2011 09:33 PM

Code:

#!/bin/bash
#historyswitch-
#Changes the state of histexpand to off when on and vice-versa
set -v
function on2off(){
echo -e "History expansion is currently ON."
echo -e "You cant use exclamation points in strings."
echo -e "Do you want me to turn it OFF? {y/n}"
read yesno
if [[ $1yesno != "n" ]]; then
        set +H
        echo -e "History expansion is now OFF."
        echo -e "Happy emphasizing."
else
        echo -e "No action taken."
fi
}
function off2on(){
echo -e "History expansion is currently OFF."
echo -e "You cant use carats to edit previous commands."
echo -e "Do you want me to turn it ON? {y/n}"
read yesno
if [[ $2yesno != "n" ]]; then
        set -H
        echo -e "History expansion is now ON."
        echo -e "Enjoy the edits."
fi
if [[ $2yesno = "n" ]]; then
        echo -e "No action taken."
fi
}
c=$(set -o | grep histexpand)
if [[ $c == *on* ]]; then
        on2off
else
        off2on
fi



you forget to put one double quotes in this line

echo -e "History expansion is currently OFF.

SilversleevesX 03-21-2011 12:44 AM

Thank you.


All times are GMT -5. The time now is 07:11 PM.