Forcing the order of arguments in function generated for a "alias"
When I create an alias like:
alias "myA" "PREFIX $argv SUFFIX"
fish genarates a function with body equivalent to:
"PREFIX SUFFIX $argv.
Is there a trick/hack/legitimate way to force the shell so that the call
myA 1234 is executed as
PREFIX 1234 SUFFIX?
I know how to do that by writing a function. I generate about 15+ of these, on the fly, and the PREFIX, SUFFIX strings keep changing very frequently. So it is not practical to write a function.
You seem to have misunderstood what the
aliascommand does. It does define a function. But it does not do the transformation you imply. It only appears to do so because you double-quoted the alias definition. Which means that
$argvis interpolated before the function is created. If, as is likely to be the case,
$argvis undefined (or the empty array) then
"PREFIX $argv SUFFIX"is equivalent to
To answer your question: No, there is no way to do what you want using the
aliascommand. Honestly, I think
aliasshould never have been added to fish as it isn't needed and simply confuses people migrating from bash where the concept of an "alias" is very different. It's trivial to replace
alias myA "PREFIX $argv SUFFIX"
function myA; PREFIX $argv SUFFIX; end