Re: [Fish-users] running functions in background
Also, if the function does not modify the state of the current shell, and you want to be able to run it in the background, there is a simple solution. Simply create a shell script that runs the function. On Sun, Sep 24, 2017 at 4:44 PM, Mark Volkmannwrote: > I see that can enter a command name (referring to an executable script > file in PATH) followed by & to run it in the background, but the same > doesn't seem to work with function names. Is there a reason why those are > treated differently? > > -- > R. Mark Volkmann > Object Computing, Inc. > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Fish-users mailing list > Fish-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/fish-users > > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] running functions in background
On Sun, Sep 24, 2017 at 4:44 PM, Mark Volkmannwrote: > I see that can enter a command name (referring to an executable script > file in PATH) followed by & to run it in the background, but the same > doesn't seem to work with function names. Is there a reason why those are > treated differently? > Mostly because doing so is ill-defined and can result in unexpected results. If the function modifies the state of the shell running it in the background (i.e., like an external command) would mean it cannot do so. Create the following function in bash (or zsh, etc.). Then type `x=abc; x; echo $x`. Then type `x=abc`, `x&`, then `echo $x`. Notice the difference? x() { x=def } The only way to do this sensibly is to simulate running it in the background by running it in a separate thread. There's an open issue discussing this. Someone just needs to write the code to implement the idea :-) -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
Re: [Fish-users] string functions on strings that start with a dash
Use "--" (double-dash), which is used to indicate the end of command options, after which only positional parameters are accepted. This works: set firstChar (string sub -s1 -l1 -- "$text") On Sun, Sep 24, 2017 at 5:47 PM, Mark Volkmannwrote: > > Suppose I have this: > set text '-foo' > > How can I determine whether the first character of the string in $text is a dash? > I tried this: > set firstChar (string sub -s1 -l1 "$text") > > But that doesn't work because "string sub" thinks I'm trying to specify another switch since $text starts with a dash, and of course "-foo" is not a valid switch for "string sub". > > -- > R. Mark Volkmann > Object Computing, Inc. > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Fish-users mailing list > Fish-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/fish-users > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
[Fish-users] string functions on strings that start with a dash
Suppose I have this: set text '-foo' How can I determine whether the first character of the string in $text is a dash? I tried this: set firstChar (string sub -s1 -l1 "$text") But that doesn't work because "string sub" thinks I'm trying to specify another switch since $text starts with a dash, and of course "-foo" is not a valid switch for "string sub". -- R. Mark Volkmann Object Computing, Inc. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users
[Fish-users] running functions in background
I see that can enter a command name (referring to an executable script file in PATH) followed by & to run it in the background, but the same doesn't seem to work with function names. Is there a reason why those are treated differently? -- R. Mark Volkmann Object Computing, Inc. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users