[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: disable IPv6 debian



On Sat, Apr 16, 2022 at 08:06:23AM +0800, wilson wrote:
> 
> 
> Greg Wooledge wrote:
> > if [ "$1" == on ]
> 
> this sounds strange. why a string doesn't need "" around in shell script?

You only need quotes to force a literal interpretation of whitespace or
other special characters, or to suppress word splitting and filename
expansion (globbing) after a substitution.

Consider a command like this:

ls -l .bashrc

You've got a command name, and you're passing two string arguments to
it.  If you feel a need to quote every string argument, then you should
be writing it like this:

ls "-l" ".bashrc"

But nobody does that.  It's simply unnecessary.  Likewise, you don't need
quotes around "on" or "off" because they don't contain special characters.
You also don't need quotes around the "==" string argument that was passed
in this command.  It's funny that you would think you should put quotes
around "on" but not around "==", isn't it.


Reply to: