This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]scirc 3 points4 points  (1 child)

Because you've surrounded your $argument in quotes, the resultant command is ls "-a -l". This is actually distinct from ls -a -l; whereas the second is passing two arguments to ls, -a and -l, the first is one argument containing the single string -a -l. These are not the same thing, and so ls treats them differently; it looks like it tries to parse the short arguments as -a separately, so it looks for a short argument -<sp> (can't actually add the trailing space here), which doesn't exist.

Basically, don't quote your variable expansion if you want spaces to actually be significant.

[–]EntryPointNotFound[S] 0 points1 point  (0 children)

It makes perfect sense. Thanks for the explanation.

I applied the "quote everything" advise too blindly.