Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'scripts': 0.03; 'exit': 0.09; 'exits': 0.09; 'omit': 0.09; 'subject:files': 0.09; 'terminated': 0.09; 'variable,': 0.09; 'python': 0.11; '11:32': 0.16; '>on': 0.16; 'command.': 0.16; 'determines': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hazard': 0.16; 'imo,': 0.16; 'loud': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'prep': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'set,': 0.16; 'simpson': 0.16; 'subject:program': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'shell': 0.22; 'to:name:python- list@python.org': 0.22; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; 'options': 0.25; 'script': 0.25; 'skip:" 20': 0.27; 'header :In-Reply-To:1': 0.27; 'appear': 0.29; 'chris': 0.29; 'statement': 0.30; 'code': 0.31; 'that.': 0.31; 'usually': 0.31; 'accidentally': 0.31; 'sep': 0.31; 'stuff': 0.32; 'run': 0.32; 'fri,': 0.33; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'fun,': 0.36; 'received:com.au': 0.36; 'skip:> 10': 0.36; 'subject:data': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'error.': 0.37; 'example,': 0.37; 'seconds': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'major': 0.40; 'expression': 0.60; 'course': 0.61; 'further': 0.61; 'back': 0.62; 'content- disposition:inline': 0.62; 'such': 0.63; 'more': 0.64; 'great': 0.65; 'sound': 0.68; 'default': 0.69; 'careless': 0.84; 'loose': 0.84; 'terrible': 0.84 Date: Sat, 20 Sep 2014 10:27:45 +1000 From: Cameron Simpson To: "python-list@python.org" Subject: Re: program to generate data helpful in finding duplicate large files MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=fvDlOjIf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=d9tRquDATOQA:10 a=fxrdlrCTMIcA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=yQbZ82wRAAAA:8 a=70Wb1Q_n4vGyxFdP5DIA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=71hhXxJ2lJkA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411172874 news.xs4all.nl 2935 [2001:888:2000:d::a6]:53416 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78092 On 19Sep2014 23:59, Chris Angelico wrote: >On Fri, Sep 19, 2014 at 11:32 PM, David Alban wrote: >> if you omit the exit statement it in this example, and >> $report_mode is not set, your shell program will give a non-zero return code >> and appear to have terminated with an error. in shell the last expression >> evaluated determines the return code to the os. > >IMO that's a terrible misfeature. If you actually want the return >value to be propagated, you should have to say so - something like: > >#!/bin/sh >run_program >exit $? > >Fortunately, Python isn't like that. IMO, it is good that the shell is like that. It isn't Python. A great many small shell scripts are one liner wrappers, and this serves them well. A great many more are a lot of prep work followed by a major (and final) command. These are also served well. There is the hazard where someone careless goes: ... main script ... echo "script failed!" >&2 and accidentally exits with 0 (success). For further fun, I run my shell scripts with the -e and -u options turned on. And of course for complicated stuff I usually maintain a $xit variable, setting it to 1 when something goes blam, and finishing such scripts with: exit $xit But for wrappers, the shell default exit design is handy. Cheers, Cameron Simpson From the back of the research lab, the sound of a large metallic pile of loose objects collapsing, accompanied by a loud "Aaaaiiieeyyrrgghhh!!" from George. A few seconds of silence, then: "I'll have to call you back."