We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sh -c 'env HOME=$(mktemp -d) fish'
fish version installed (fish --version): 2.4.0
fish --version
OS/terminal used: OSX 10.12.2 (16C67) / iTerm2 Build 3.0.13
Let's say I have a simple script that just outputs its arguments. It could look something like this:
#!/usr/bin/env ruby p ARGV
and its execution looks like this:
> ./myscript.rb foo 'hello world' ["foo", "hello world"]
Notice how "hello world" is grouped as one argument vs "hello" and "world" being separate arguments.
Now, I want to write a fish function that lets me execute any arbitrary fish command (including aliases) with some ENV vars set up.
This is my first attempt of such function
function debug set -xg DEBUG 1 eval $argv set -e DEBUG end
Here's what happens when I run my script from above through this function:
> debug ./myscript.rb foo 'hello world' ["foo", "hello", "world"]
Notice that single "hello world" argument turned into "hello" and "world", which is not what I wanted.
I've also tried the following approach:
env DEBUG=1 fish -c "$argv"
Which produced the same result.
Is there any way to make the function's $argv preserve "hello world" grouping? What am I missing?
$argv
The text was updated successfully, but these errors were encountered:
This is a problem with eval, not the "$argv" in particular.
eval
eval parses its arguments as if they were given on the commandline, and it doesn't care about how the arguments are split.
We've had an issue about this before, but the consensus was that we can't change eval now, and that it might make other things trickier.
What we are trying to do know is in #154 - make command and such accept variables.
command
That would mean you could add command $argv, and it would run it like you expect.
command $argv
Sorry, something went wrong.
Note that currently you can use string escape, i.e. eval (string escape -- $argv).
string escape
eval (string escape -- $argv)
Thanks. (string escape -- $argv) worked.
(string escape -- $argv)
No branches or pull requests
sh -c 'env HOME=$(mktemp -d) fish'
)?fish version installed (
fish --version
): 2.4.0OS/terminal used: OSX 10.12.2 (16C67) / iTerm2 Build 3.0.13
Let's say I have a simple script that just outputs its arguments. It could look something like this:
and its execution looks like this:
Notice how "hello world" is grouped as one argument vs "hello" and "world" being separate arguments.
Now, I want to write a fish function that lets me execute any arbitrary fish command (including aliases) with some ENV vars set up.
This is my first attempt of such function
Here's what happens when I run my script from above through this function:
Notice that single "hello world" argument turned into "hello" and "world", which is not what I wanted.
I've also tried the following approach:
Which produced the same result.
Is there any way to make the function's
$argv
preserve "hello world" grouping? What am I missing?The text was updated successfully, but these errors were encountered: