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

Re: preventing the leading space in process substitution



martin f krafft wrote:
> I am trying to use <(...) to pass a file to a command that expects
> the file argument following an equal sign, like so:
> 
>   mycommand -file=/path/to/some/file
> 
> The problem is that
> 
>   mycommand -file=<(...)
> 
> seems to yield
> 
>   mycommand -file= /proc/self/fd/16
> 
> with the space before the filename. How do I prevent that?

For reasons buried in history that I don't understand, the <(...) is
parsed as a single complete argument.  It's somewhat laconically
documented that they are "command arguments" and not parts of an
argument.  This may just have been laziness.

You can use a front end function:

mycommand_file() {
  mycommand -file=$1 "${(@)argv[2,-1]}"
}
mycommand_file <(...)

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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