Comment on mv *.jpg is complete bullshit.

<- View Parent
GenderNeutralBro@lemmy.sdf.org ⁨8⁩ ⁨months⁩ ago

Some hideous escape syntax ought to force *.jpg to appear as “-a.jpg” instead of -a.jpg, once it reaches mv

The issue here is that there’s no difference here between -a.jpg and “-a.jpg”.

Go ahead and try these commands. They are 100% equivalent:

ls -laR
ls "-laR"
ls '-laR'

The reason these are equivalent is because quoting (and expansion, and globbing) is processed in the shell. The shell then passes the evaluated string as an argument to the tool. All of those evaluate to the same string, so they look exactly the same to the ls command.

What is the solution if there’s a file name that matches something the tool thinks is an argument? What would the correct behavior be?

The only solution is to include some way to communicate to the tool what each argument is. In practice, you could do ls – * and it would work even if the first filename was “-laR”. However, not all tools use the convention. This is really core to the design of the OS, in that command arguments have no type.

source
Sort:hotnewtop