lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] It this temporary file good, or bad?


From: Vadim Zeitlin
Subject: Re: [lmi] It this temporary file good, or bad?
Date: Wed, 15 Jun 2022 03:26:01 +0200

On Wed, 15 Jun 2022 00:24:47 +0000 Greg Chicares <gchicares@sbcglobal.net> 
wrote:

GC> Vadim--Please consider commit ae17ea6bdfdc, which adds this
GC> makefile target:
GC> 
GC> show_overlooked_cxx_warnings:
GC>        @$(CXX) $(ALL_CXXFLAGS) -Q --help=warning -xc++ /dev/null \
GC>          | $(GREP) '[[]disabled[]]' \
GC>          | $(SED) -e's/[ \t]*[[]disabled[]]//' -e's/^ *-W//' \
GC>          > eraseme
GC>        @$(GREP) -of eraseme $(this_makefile) | $(GREP) -vxf - eraseme || 
true
GC>        @$(RM) eraseme
GC> 
GC> It seems to work just fine, but it troubles me that I couldn't
GC> find a way to do this without a temporary file.

 To be honest, what troubles me is that this looks very clever. And IMO
neither makefiles nor shell scripts should contain anything clever, but
should rather be as simple as possible, as they're already difficult enough
to understand due to the idiosyncratic make syntax.

GC> Isn't there a better, more unixy way that avoids that file?

 I don't know if it's really Unixy, but IMHO the best way would be an
obvious one of writing an awk (or Perl) few-liner doing this instead of
doing it with shell.

GC> Reusing the same stream twice seems to call for 'tee', but I don't see
GC> how to make it work here.

 It probably could be made to work with zsh-specific process substitution
allowing to use >(some command) as tee argument, but it clearly can't be
done in standard POSIX shell as tee there would always create a file, and
this file would necessarily be temporary, as we don't want any permanent
files to be created here.

GC> What would a unix master do?

 I don't know, but personally I'd use a more appropriate tool for this not
quite trivial job here.

 But, again, the solution above is clever and works (and could be used in a
quiz of shell knowledge in a pinch).

 Regards,
VZ

Attachment: pgpNM68VFwTAY.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]