1

Is there any reason for doing something like:

a="abc"

or

a='abc'

The quotes seem completely superfluous, but then there might be some hideous corner case... I'm interested in Bash and Sh in particular, but answer about the other ones as well if you can and will.

3
  • Linking in for related questions: unix.stackexchange.com/questions/400447/… and unix.stackexchange.com/questions/97560/…
    – Jeff Schaller
    Jun 17 '18 at 1:17
  • 1
    The only reason I quote the right hand side of an assignment like that (static string) is if anyone later decides that they'd want a space in the string (e.g. it's a long pathname that someone might modify, not realizing it's unquoted).
    – Kusalananda
    Jun 17 '18 at 6:49
  • 1
    Sure, you could drop the quotes for simple cases like that, but I don't advise it. You want to train your brain so that quoting becomes second nature. That way, you're much less likely to forget to quote when it's critical to do so, and you'll find it easier to debug, since stuff with missing quotes will look obviously wrong.
    – PM 2Ring
    Jun 17 '18 at 10:17