On Fri, Aug 18, 2017 at 4:12 PM, Greg Reagle <greg.rea...@umbc.edu> wrote:

> On Fri, Aug 18, 2017, at 18:51, Kurtis Rader wrote:
> > Add this to the top of the function:
> >
> > set -q language[1]
> > or set language english
>
> There is a potential problem with the above though.  If $language is set
> to the empty string, the above code will not set language to english
> [1].  I say potential because I don't know if that is a realistic cause
> for a concern or a theoretical possibility that is highly unlikely.  In
> either case, to handle a defined yet empty string, try these (from [1]):


I would argue that if it has been explicitly set to an empty string then it
is in fact set and the default should not be applied. That approach is more
"fishy" since fish does not suffer from the interpolation, extra word
splitting, and other general nastiness of dealing with variables in POSIX
shells like bash. Having said that your advice is good if it is possible
for the var to be set to an empty string and that should be handled
differently from any other random string like "." it might have been set to.

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

Reply via email to