6 ms·
It clashes with command line switches. dir /w does not list the contents of the directory called w.
by sz4kerto 11y ago
It clashes with command line switches. dir /w does not list the contents of the directory called w.
- douche 11y agoOn Windows, you've really got to be quoting your paths everywhere anyway, since spaces abound, and if you do that, then dir "/w" works as expected.
- ygra 11y agoConsidering that most file systems these days allow spaces in paths, I'd guess you can safely remove the »On Windows« there. The amount of shell and build scripts on Unix-likes that die horrible deaths when encountering spaces is not funny. And well, yes, in a way that probably means that spaces in paths are not »supported« there, but you could then say the same about Windows. As well as using non-ASCII in paths.
- fnbr 11y ago> The amount of shell and build scripts on Unix-likes that die horrible deaths when encountering spaces is not funny. That's so accurate. I used to write shell scripts with command $1 until I got a few too many nasty surprises with dashes in filenames.
- pdkl95 11y agoAlways use "$@" foo() { for arg in "$@" ; do echo "arg is \"${arg}\"" done } foo 'bar baz' 'spaces in filename.txt' > dashes in filenames. When writing shell scripts it's a good idea to use the -- option whenever possible stupid_backup() { cp -a -- "$@" /stupid/backup/dir/ } # copies 2 files stupid_backup --files '-with -leading -dashes'
- fnbr 11y agoWhat does the -- option do? I haven't encountered that before.
- QuercusMax 11y agoIt means "everything past here should not be parsed as a - or -- flag". If you have a file named "-l", then ls -- -l will show you that file, instead of doing a long listing.
- OJFord 11y agoNot everything's a script though. I avoid using spaces, so I'm in the habit of (outside of a script) not quoting; if I bump into a space within a path then by that point it's just quicker to escape it.