zsh-users
 help / color / mirror / code / Atom feed
* why does this exit = 1 ?
@ 1998-04-05  8:00 Timothy J Luoma
  1998-04-05  8:22 ` Michael Barnes
  0 siblings, 1 reply; 4+ messages in thread
From: Timothy J Luoma @ 1998-04-05  8:00 UTC (permalink / raw)
  To: zsh-users


I have this little snippet:

if [ -r /LocalLibrary/Images/Icons/tempPark.tiff -a ! -r /tmp/.dir.tiff ] then   
         ln -s /LocalLibrary/Images/Icons/tempPark.tiff /tmp/.dir.tiff

fi

When I run it and there is already a /tmp/.dir.tiff it exits = 1

I am curious why it does that, since there shouldn't be any 'error' --- or  
am I missing something?

TjL




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why does this exit = 1 ?
  1998-04-05  8:00 why does this exit = 1 ? Timothy J Luoma
@ 1998-04-05  8:22 ` Michael Barnes
  1998-04-05 14:27   ` C. v. Stuckrad
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Barnes @ 1998-04-05  8:22 UTC (permalink / raw)
  To: Timothy J Luoma; +Cc: zsh-users

The if statement returns false so the script returns false (1),
if you want the script to return true just add exit 0 at the end.

Mike

On Sun, 5 Apr 1998, Timothy J Luoma wrote:

> 
> I have this little snippet:
> 
> if [ -r /LocalLibrary/Images/Icons/tempPark.tiff -a ! -r /tmp/.dir.tiff ] then   
>          ln -s /LocalLibrary/Images/Icons/tempPark.tiff /tmp/.dir.tiff
> 
> fi
> 
> When I run it and there is already a /tmp/.dir.tiff it exits = 1
> 
> I am curious why it does that, since there shouldn't be any 'error' --- or  
> am I missing something?
> 
> TjL
> 
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why does this exit = 1 ?
  1998-04-05  8:22 ` Michael Barnes
@ 1998-04-05 14:27   ` C. v. Stuckrad
  1998-04-09  5:50     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: C. v. Stuckrad @ 1998-04-05 14:27 UTC (permalink / raw)
  To: Michael Barnes; +Cc: Timothy J Luoma, zsh-users


strange thou, it works for me, tested it in a zsh-function!
I did

try() {
 if [ ! -r ... ]
 then echo no file
 fi
}

and tested with 'try; echo $?'

and file or no file the result was 0
(on zsh or sh;  Sun or LINUX(where sh==bash)

So what does happen really ?

Stucki

On Sun, 5 Apr 1998, Michael Barnes wrote:

> Subject: Re: why does this exit = 1 ?
> Date: Sun, 5 Apr 1998 04:22:20 -0400 (EDT)
> 
> The if statement returns false so the script returns false (1),
> if you want the script to return true just add exit 0 at the end.
...
> On Sun, 5 Apr 1998, Timothy J Luoma wrote:
> > I have this little snippet:
> > ...
> > if [ -r /LocalLibrary/Images/Icons/tempPark.tiff -a ! -r /tmp/.dir.tiff ] then   
> >          ln -s /LocalLibrary/Images/Icons/tempPark.tiff /tmp/.dir.tiff
> > fi
> > 
> > When I run it and there is already a /tmp/.dir.tiff it exits = 1


Christoph von Stuckrad       * *  | talk to  | <stucki@math.fu-berlin.de> \
Freie Universitaet Berlin    |/_* | nickname | ...!unido!fub!leibniz!stucki|
Fachbereich Mathematik, EDV  |\ * | 'stucki' | Tel:+49 30 838-75459        |
Arnimallee 2-6/14195 Berlin  * *  |  on IRC  | Fax:+49 30 838-75454       /


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why does this exit = 1 ?
  1998-04-05 14:27   ` C. v. Stuckrad
@ 1998-04-09  5:50     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1998-04-09  5:50 UTC (permalink / raw)
  To: zsh-users; +Cc: C. v. Stuckrad, Michael Barnes, Timothy J Luoma

This has been sitting in my mailbox for a few days ...

On Apr 5,  4:27pm, C. v. Stuckrad wrote:
} Subject: Re: why does this exit = 1 ?
}
} strange thou, it works for me, tested it in a zsh-function!
} 
} So what does happen really ?
} 
} > On Sun, 5 Apr 1998, Timothy J Luoma wrote:
} > > I have this little snippet:
} > > ...
} > > if [ -r /LocalLibrary/Images/Icons/tempPark.tiff -a ! -r /tmp/.dir.tiff ] then   
} > >          ln -s /LocalLibrary/Images/Icons/tempPark.tiff /tmp/.dir.tiff
} > > fi
} > > 
} > > When I run it and there is already a /tmp/.dir.tiff it exits = 1

Two guesses:

1.  It's the alias-for-fi problem again, but something else is masking the
    syntax error.

2.  /tmp/.dir.tiff exists but is not readable, so [ ! -r /tmp/.dir.tiff ]
    succeeds but ln fails.  Try [ ! -f /tmp/.dir.tiff ].

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-04-09  6:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-05  8:00 why does this exit = 1 ? Timothy J Luoma
1998-04-05  8:22 ` Michael Barnes
1998-04-05 14:27   ` C. v. Stuckrad
1998-04-09  5:50     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).