Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78092
| Date | 2014-09-20 10:27 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: program to generate data helpful in finding duplicate large files |
| References | <CAPTjJmp6zPKOihn-ubrQGbL-bMXwk+m0rBowoWOy=rqEbnAxaA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14156.1411172874.18130.python-list@python.org> (permalink) |
On 19Sep2014 23:59, Chris Angelico <rosuav@gmail.com> wrote: >On Fri, Sep 19, 2014 at 11:32 PM, David Alban <extasia@extasia.org> 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 <cs@zip.com.au> 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."
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: program to generate data helpful in finding duplicate large files Cameron Simpson <cs@zip.com.au> - 2014-09-20 10:27 +1000
csiph-web