Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Feature request: set extension for =( ) created file

On Sep 25,  7:58pm, Nikolay Aleksandrovich Pavlov (ZyX) wrote:
} 25.09.2016, 08:19, "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>:
} > The "mktemp" utility is designed to cover nearly all of these cases,
} This is an argument against `=()` as a whole, not against my proposal.

Quite the contrary.  =() is intended to solve a very specific and very
common case:  capture the output of a command and immediately make use
of it, then discard it automatically.  It differs from a pipe in only
two very deliberate ways:  it provides a file name when a command is
not able to read stdin, and it is seek-able.

There is no corresponding *common* case for any of your suggestions; it
rarely makes sense to create and immediately discard an empty directory,
and it seldom makes sense to create and discard a file with a specific
name.[*]  The existence of a more complete solution for complicated
cases neither invalidates the simple solution to the simple case nor
justifies turning the simple solution into a complicated one.

[*] This is not to say that there isn't a use case that might be done
a hundred times in a day that needs a specific name, just that there
are not a large number of different commonly-occuring such use cases.

} > However, neither that nor any of your suggestions would accomplish
} > altering the filename based on the file content.
} This feature is not what OP requested.

Nearly everyone seems to have interpreted it that way, even though
Sebastian has now said that's not what he meant ... but:

What's potentially wanted is a syntax that means "take file X, make
a link to it named Y, include Y in the set of files to be unlinked
when this command context is finished, and substitute Y into the
command line in place of X."  I simulated that with my "fixfiletype"
precommand-modifier-ish wrapper function.  How you generate Y should
not need to have anything to do with where X came from.

The TMPSUFFIX idea is part-way to this, but it still ties Y to X.
It might even be possible to have a TMPFILENAME value that entirely
repaces the mktemp(3) file name, though that wouldn't work if there
are multiple =() on the same command line.

Messages sorted by: Reverse Date, Date, Thread, Author