0

Is something like this possible with fish? i.e.

switch $var
  case a-z
    do something
  case "*"
    do something else
end

case "*"works fine, but case a-zdoesn't trigger. I also tried case [ a-z ] but no joy.

1 Answer 1

1

The fish shell has not, for some reason, implemented character sets. Assuming you're using the latest version, use the string command

if string match --quiet --regex '[a-z]' $var >/dev/null
    echo $var contains a letter
else
    echo $var has no letters
end

I'm using regex matching due to the minimal glob patterns in fish

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.