program to generate data helpful in finding duplicate large files

Chris Angelico rosuav at gmail.com
Sat Sep 20 06:53:39 CEST 2014


On Sat, Sep 20, 2014 at 10:27 AM, Cameron Simpson <cs at zip.com.au> wrote:
> 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.

What you're saying here is that there are times when it's convenient,
and other times when it's inconvenient. And sure! That's definitely
true. What I contest, though, is that having it this way is the better
design. Even if the bulk of shell scripts are wrappers for single
commands and want to exit with their return values (which I suspect is
not the case), I believe the better design would be to have them put a
simple tag onto it like "|| exit $?". Of course, there's no changing
it now.

ChrisA



More information about the Python-list mailing list