LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 03-20-2011, 09:19 PM   #1
SilversleevesX
Member
 
Registered: May 2009
Posts: 181
Blog Entries: 9

Rep: Reputation: 15
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

Last edited by SilversleevesX; 03-20-2011 at 09:22 PM.
 
Old 03-20-2011, 09:33 PM   #2
anishkumarv
Member
 
Registered: Feb 2010
Location: chennai - India
Distribution: centos
Posts: 289

Rep: Reputation: 10
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.
 
1 members found this post helpful.
Old 03-21-2011, 12:44 AM   #3
SilversleevesX
Member
 
Registered: May 2009
Posts: 181
Blog Entries: 9

Original Poster
Rep: Reputation: 15
Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 6 03-21-2013 11:35 AM
script using "/usr/bin/cat error" produces "cannot open" in cron Dcrusoe Programming 6 07-22-2009 04:30 PM
Simple bash script "unexpected end of line error" snowman81 Programming 11 11-11-2007 10:31 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 10:00 AM
bash "unexpected end of file" script error Runge_Kutta Linux - General 6 05-23-2007 04:36 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration