Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!mandrill!hal!ncoast!allbery From: allbery@ncoast.UUCP Newsgroups: comp.bugs.sys5 Subject: Re: sh bug Message-ID: <5693@ncoast.UUCP> Date: Mon, 16-Nov-87 22:20:37 EST Article-I.D.: ncoast.5693 Posted: Mon Nov 16 22:20:37 1987 Date-Received: Fri, 20-Nov-87 22:00:57 EST References: <467@virginia.acc.virginia.edu> <706@its63b.ed.ac.uk> <318@igloo.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: comp.bugs.sys5 Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 27 As quoted from <318@igloo.UUCP> by billw@igloo.UUCP (Bill Wisner): +--------------- | In article <706@its63b.ed.ac.uk> simon@its63b.ed.ac.uk (Simon Brown) writes: | >Dat's 'cos the first cd fails, so the shell interrupts itself (well, sort of), | >and jumps straight back to command level - without executing the second part of | >the "||". What you'll have to do is force the first component to be executed | >in a subshell so it can't effect the second - like | [example using (cd nowhere) deleted] | | Sorry, I'm afraid not. Doing a cd in a subshell will do absolutely no good. | The subshell will change directories, but immediately afterwards it will exit, | leaving the original shell back where it started. +--------------- Did you *really* look at the example? It cd's twice. (cd nowhere) 2> /dev/null && cd nowhere The first one has no effect -- except that we get an exit status nonzero if the directory doesn't exist. This allows (in a klugey way) testing the exit status of a cd. Me? I use ksh. -- Brandon S. Allbery necntc!ncoast!allbery@harvard.harvard.edu {hoptoad,harvard!necntc,{sun,cbosgd}!mandrill!hal,uunet!hnsurg3}!ncoast!allbery Moderator of comp.sources.misc