Making one (the easy part) ... could be as easy as
Code:
alias grep `/U wsl grep`
Using one (the hard part) ... when an alias starting with "/U" is invoked it should look at the command line and ...
Code:
if it looks like a file name, use @WSLPATH on it
I suspect that that would be easy for files that exist, but require a bit of AI for a file that doesn't exist, for example, an output file for WSL's sort.
Or maybe a special switch (/U again?) ... only meaningful in /U aliases ... meaning use @WSLPATH on the next parameter, perhaps ...
One strategy works pretty well in a BTM (though I haven't considered all that could go wrong). I first used "/u:filename" as an indication that the argument needed @wslpath but that thwarted file name completion. So I used "/u filename" as suggested in my previous post.
Code:
v:\> type usort.btm
set command=wsl sort
do i=1 to %#
iff "%[%i]" == "/u" then
shift
set command=%command "%@wslpath[%[%i]]"
else
set command=%command %[%i]
endiff
enddo
%command
v:\> type infile
3
2
1
v:\> usort /u infile
1
2
3
v:\> del outfile
Deleting V:\outfile
1 file deleted
v:\> usort /u infile -o /u outfile
v:\> type outfile
1
2
3
v:\> type infile | usort.btm
1
2
3
v:\> del outfile
Deleting V:\outfile
1 file deleted
v:\> type infile | usort.btm -o /u outfile
v:\> type outfile
1
2
3
v:\>
I did the same thing with a plugin command (LX). That worked as well as the library routine. Using a plugin plugin cuts down reduces the number of times special symbols must be escaped by escaping &, &&, |, and || (which were unescaped by the parser) and by doubling %s and unquoted ^s (which were un-doubled by the parser). So I can do the likes of this (nonsense, but a decent example). Here's a debug (/D) version which just prints the resulting command.
It would be nice if I didn't have to escape or double anything. That is to have an alias or command that would be exempt from the normal parsing: i.e.,which would send the command line, as is, to WSL. I'm sure I can't do that with a BTM, an alias, or a plugin. And I don't know if TCC itself can do it.
So, at the moment, I don't know about this suggestion.
How about a separate command, e.g., ALIASL or LALIAS or WSLAlias ?
An advantage of that would be that just looking at the command name in the declaration would immediately indicate it will work differently from an equivalent ALIAS.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.