LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-12-2010, 11:43 AM   #1
mirlin510
LQ Newbie
 
Registered: Jul 2010
Posts: 12

Rep: Reputation: 0
Bash Script -- I'm stumped


echo $overwriteWorkspaceEnv

if [ $overwriteWorkspaceEnv="yes" ]; then
echo new workspace
else
echo old workspace
fi

This is what prints out:

no
new workspace

I'm confused why the script is printing out "new workspace", when overwriteWorkspaceEnv is equal to "no". Shouldn't it print out "old workspace", since overwriteWorkspaceEnv equals "no"? I tried changing the else to an elif with $overwriteWorkspaceEnv="no" as the argument and nothing changed.

Any able would be appreciated.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-12-2010, 11:53 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
you need spaces in a 'test' statement between all the tokens
and it's advisable to quote a variable, or else if it's null it will blow up.

Code:
if [ "$overwriteWorkspaceEnv" = "yes" ]; then
man test
 
2 members found this post helpful.
Old 07-12-2010, 11:56 AM   #3
mirlin510
LQ Newbie
 
Registered: Jul 2010
Posts: 12

Original Poster
Rep: Reputation: 0
I certainly feel dumb. That works, thanks.
 
Old 07-12-2010, 12:09 PM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
don't.
we've all done it, even me!
 
Old 07-13-2010, 12:50 PM   #5
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
me tooooo
 
0 members found this post helpful.
  


Reply



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
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 06:00 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM
I'm stumped - Script question t3kn0lu5t Linux - Newbie 6 09-26-2003 01:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:24 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
Open Source Consulting | Domain Registration