git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 10/16] engine.pl: delete the captured stderr file if empty

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 20, 2015, 06:40 UTC
Message-ID
<CAPig+cRZgjnxrYRVYCLuzomE=qQtF9N_SE6t5kLcXbdiheNeTg@mail.gmail.com>
In-Reply-To
<FDE2D068444A4350B0C2F25275CBC41D@PhilipOakley>
On Mon, Jul 20, 2015 at 2:16 AM, Philip Oakley <philipoakley@iee.org> wrote:
Show 29 quoted lines
> From: "Eric Sunshine" <sunshine@sunshineco.com>
>> On Sun, Jul 19, 2015 at 4:08 PM, Philip Oakley <philipoakley@iee.org>
>> wrote:
>>> Keep the build clean of extraneous files if it is indeed clean.
>>> Otherwise leave the msvc-build-makedryerrors.txt file both as
>>> a flag for any CI system or for manual debugging.
>>>
>>> Note that the file will contain the new values of the GIT_VERSION
>>> and GITGUI_VERSION if they were generated by the make file. They
>>> are omitted if the release is tagged and indentically defined in
>>> their respective GIT_VERSION_GEN file DEF_VER variables.
>>>
>>> Signed-off-by: Philip Oakley <philipoakley@iee.org>
>>> ---
>>> +# test for an empty Errors file and remove it
>>> +for ($ErrsFile) {unlink $_ if (-f $_) && (!-s $_);}
>>
>> Why the 'for' loop?
>>
>> Also, if you're using the 'for' loop for the $_ side-effect, then why
>> not the simpler:
>
> It was cargo cult programming, with some Google searching to select between
> invocations. Most examples were looping through lists in scripts, hence the
> down select.
>
>>    for ($ErrsFile) { unlink if -f && !-s; }
>
> A lot better. Will fix.

Although that works, I'm not sure that it's really all that desirable due to the unnecessary and potentially confusing 'for' loop. I'd probably just write it as:

    unlink $ErrsFile if -f $ErrsFile && !-s _;

The lone '_' is magical[1] in that it re-uses the stat() information from the -f rather than stat'ing $ErrsFile again. I'd also probably replace !-s ("not non-zero size") with -z ("zero size"):

    unlink $ErrsFile if -f $ErrsFile && -z _;

And, if you're using Perl 5.10 or later, you could use a little syntactic sugar[1] and stack the file test operators up against one another:

    unlink $ErrsFile if -f -z $ErrsFile;
which is the equivalent of the above with the sugar removed.
[1]: http://perldoc.perl.org/functions/-X.html
-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Previous: Philip OakleyNext: Philip Oakley
Message 16 of 26 in “Make the msvc-build scripts work again”
  1. 00/16 Make the msvc-build scripts work againPhilip Oakley, Jul 19, 2015
  2. 01/16 perl/Makefile: treat a missing PM.stamp as if emptyPhilip Oakley, Jul 19, 2015
  3. 02/16 .gitignore: improve MSVC ignore patternsPhilip Oakley, Jul 19, 2015
  4. 03/16 .gitignore: ignore library directories created by MSVC VS2008 buildsystemPhilip Oakley, Jul 19, 2015
  5. 04/16 (msvc-build) Vcproj.pm: remove duplicate GUIDPhilip Oakley, Jul 19, 2015
  6. 05/16 engine.pl: fix error message (lib->link)Philip Oakley, Jul 19, 2015
  7. 06/16 engine.pl: Properly accept quoted spaces in filenamesPhilip Oakley, Jul 19, 2015
  8. 07/16 engine.pl: Fix i18n -o option in msvc buildsystem generatorPhilip Oakley, Jul 19, 2015
  9. 08/16 engine.pl: ignore invalidcontinue.obj which is known to MSVCPhilip Oakley, Jul 19, 2015
  10. Eric SunshineJul 20, 2015
  11. Philip OakleyJul 20, 2015
  12. 09/16 engine.pl: name the msvc buildsystem's makedry error filePhilip Oakley, Jul 19, 2015
  13. 10/16 engine.pl: delete the captured stderr file if emptyPhilip Oakley, Jul 19, 2015
  14. Eric SunshineJul 20, 2015
  15. Philip OakleyJul 20, 2015
  16. Eric SunshineJul 20, 2015
  17. Philip OakleyJul 20, 2015
  18. Eric SunshineJul 20, 2015
  19. 11/16 engine.pl: add debug line to capture the dry-runPhilip Oakley, Jul 19, 2015
  20. 12/16 engine.pl: provide more debug print statementsPhilip Oakley, Jul 19, 2015
  21. 13/16 Vcproj.pm: list git.exe first to be startup projectPhilip Oakley, Jul 19, 2015
  22. 14/16 vcbuild/readme: Improve layout and reference msvc-build scriptPhilip Oakley, Jul 19, 2015
  23. Philip OakleyJul 19, 2015
  24. 14/16 vcbuild/readme: Improve layoutPhilip Oakley, Jul 19, 2015
  25. 15/16 msvc-build: add complete Microsoft Visual C compilation scriptPhilip Oakley, Jul 19, 2015
  26. 16/16 config.mak.uname: add MSVC No_SafeExeceptionHandler optionPhilip Oakley, Jul 19, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.