Skip Navigation

why does noone inprove bash such that you can write a normal foor loop with whitespace in file names?

I know that there are ten different alternatives. Why don't we simply improve the basic stuff?

41

You're viewing a single thread.

41 comments
  • It has nothing to do with bash specifically - other shells like sh, csh, tcsh, zsh, etc. are the same. Whitespace in UNIX is just that way by design. And it's been a long while since I used a Windows CLI but they were that way too - plus added all that weirdness about ~1 at the ends of filenames, and Mac OSX also. So not even just UNIX, but it's how the CLIs tend to work, where whitespace acts as the "delimiter" between arguments sent to a program.

    program_name arg1 arg2 arg3 arg4

    So if you use whitespace like "cp file 1 file 2", the CLI sends arg1="file", arg2="1", arg3="file", arg4="2", rather than arg1="file 1" and arg2="file 2". These are just the foundational rules of how CLIs work - a computer can't read your mind, and this is how you precisely tell it what you want, within this highly rigid framework to avoid misunderstandings.

    The alternative is to use a GUI, so like see file, drag file, and ofc that has its own set of tradeoffs good and bad.

You've viewed 41 comments.