Of course a more simple
also works.
FYI, many core terminal utilities know of the special "--" parameter as well, not only yt-dlp.
E.g. you have files called "-silly-filename" and "--silly-filename2"
Code: Select all
guest@porteus:~$ cd /tmp
guest@porteus:/tmp$ touch -- -silly-filename --silly-filename2
Now trying to use ls to look at details fails:
Code: Select all
guest@porteus:/tmp$ ls -o -silly-filename --silly-filename2
/bin/ls: invalid option -- 'y'
Try '/bin/ls --help' for more information.
but adding -- at the right place succeeds:
Code: Select all
guest@porteus:/tmp$ ls -o -- -silly-filename --silly-filename2
-rw-r--r-- 1 guest 0 2022-11-05 07:26 --silly-filename2
-rw-r--r-- 1 guest 0 2022-11-05 07:26 -silly-filename
I looked into man ls and found no mention on option "--"
In short,
option "--" means "end of options, rest is other parameters or filenames given to the program, but no program specific options"
Therefore
reads option "-o" filename "-silly-filename"
while
reads "no options", filenames "-o" and "-silly-filename" which will fail for filename "-o":
Code: Select all
guest@porteus:/tmp$ ls -- -o -silly-filename
/bin/ls: cannot access '-o': No such file or directory
-silly-filename
HTH.