`string match` is a good choice here as well:

 if string match -q -- '-*' $test; echo yes; end



On Sun, Sep 24, 2017 at 9:35 PM, Alex Boisvert <alex.boisv...@gmail.com>
wrote:

> 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
>
>


-- 
*Glenn Jackman*
Senior Software Developer

*Pythian - Love your data*
jack...@pythian.com
Tel: +1 613 565 8696 Ext. 1478
Mobile: +1 613 808 4984
www.pythian.com

-- 


--



------------------------------------------------------------------------------
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

Reply via email to