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 Volkmann <r.mark.volkm...@gmail.com>
wrote:
>
> 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