By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

bash-like command substitution?

Sorry if this is a common question, I wasn't able to find it after looking for a bit.

Is there a way to do bash-like command substitution? e.g.

[C:\some\dir] vim $(dir /B)

would first run `dir /B` on the directory and then feed that resultant string to vim, which would open every file in the directory. Is there a way to do similar things in tcc?
You can grab one line of a command's output with the @EXECSTR function. Multiple lines, however, are not supported, probably because most Windows executables don't expect to find EOLs embedded in the command line.

The good news is that most Windows programs can expand wildcards themselves. I haven't fooled with vim for years, but you can try
vim *

If vim doesn't support this, then you can expand wildcards with @EXPAND:
vim %@expand[*]

If you do this sort of thing a lot, it's probably worthwhile to define an alias....
You can grab one line of a command's output with the @EXECSTR function.
But you can use TPIPE to turn newlines into spaces to achieve a more general form of substitution. Below, I don't know how to get quotes around file names that need them (like the first file name, "a b.txt"). I don't think any form of DIR will do it. Maybe TPIPE will ... ?

v:\> echo %@execstr[dir /b /a:-d [ab]*.txt | tpipe /replace=4,0,0,0,0,0,0,0,0,"\r\n"," "]
a b.txt bigbig.txt bigfile.txt bkshortcuts.txt
POSIX requires shell to expand command line before passing it to called process, and the parameters are passed as a list.
Windows, on the contrary, leave command line expansion to the application, and there's simply no way to pass arguments as a list to the called command.

TL;DR: This is not humanly possible.

Similar threads