FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 02-18-2012, 11:56 AM
Johnny Rosenberg
 
Default if – in what situations does this work?

I tried this with the $? variable, but failed. Seems like [[ $? ]] is
always true no matter the value of $?. [[ $? == 0 ]] seems to work,
though.

I thought that ”if [[ $? ]]” means ”if $? is True”. What is True
anyway? 0? 1? Anything but 0?

I am not sure what I am asking for here, but any kind of input in the
subject is welcome. Thanks.


Kind regards

Johnny Rosenberg
ジョニー・*ーゼンバーグ

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 02-18-2012, 12:59 PM
"franz.reitinger"
 
Default if – in what situations does this work?

First of all I suppose you're using the bash.
Amoung others the shell treats several parameters specially; these
parameters may only be referenced and assignement to them is not
allowed.


One of them is $?, which expands to the exit status of the most
recently executed command. However, the exit status 0 means that the
command has been executed without errors; any other return value has to
be interpreted as error code.

e.g.
# any command ...
if [ $? -ne 0 ]; then
# error handling
fi

/franzR
On Sat, 18 Feb 2012 13:56:50 +0100, Johnny Rosenberg wrote:

I tried this with the $? variable, but failed. Seems like [[ $? ]] is
always true no matter the value of $?. [[ $? == 0 ]] seems to work,
though.

I thought that ”if [[ $? ]]” means ”if $? is True”. What is True
anyway? 0? 1? Anything but 0?

I am not sure what I am asking for here, but any kind of input in the
subject is welcome. Thanks.


Kind regards

Johnny Rosenberg
ジョニー・*ーゼンバーグ
/*
************************************************** **********

* Mail checked by Avira virus scanner (mail.htl-wels.at).
************************************************** **********
*/



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 08:37 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org