Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 8th June 2011, 08:13 AM
rahulvishwa Offline
Registered User
 
Join Date: Jun 2011
Posts: 2
linuxfedorakonqueror
why we get 0 for both conditions in shell scripting.?

#!/bin/bash

str3=""

if [ -z $str3 ] ; then

echo " \$? = $? "

fi

if [ -n $str3 ]
then
echo " \$? = $? "
fi

exit 0

output:-
$? = 0
$? = 0

why we get 0 for both conditions?
I am using FC15.
Reply With Quote
  #2  
Old 8th June 2011, 08:36 AM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
linuxfedorafirefox
Re: why we get 0 for both conditions in shell scripting.?

You have to double-quote the variable or use the [[ ... ]]] construct
Reply With Quote
Reply

Tags
shell script programming.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripting - please need help malaka19 Using Fedora 4 20th January 2008 03:18 PM
shell scripting haaidy Programming & Packaging 5 14th January 2008 10:42 PM
shell scripting Baby Chen Programming & Packaging 32 11th February 2006 06:46 PM
shell scripting jim Programming & Packaging 8 10th May 2005 05:18 PM


Current GMT-time: 04:05 (Sunday, 19-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat