I wouldn't change the way bash works because I'm already used to it. After a while, one gets used to it. It's like working in a hazardous environment, full of spinning blades and spikes coming out the wall at random intervals :)
But seriously, that's an accident waiting to happen. Like a less knowledgeable user trying to delete a file named *
And there are some really awful things you can do by abusing shell expansion. Like this example (WARNING: DON'T BLINDLY RUN THESE!).
Go to a directory with non-important files, and do:
touch ./-f
touch ./-r
rm *
Since there's a good chance that all of your files have sensible names (that is, they don't start with weird symbols), that will expand to:
rm -f -r [the rest of your files]
Oops. Kiss your files AND directories goodbye. That includes write protected files that would give rise to a warning if you tried to remove them. And in a cruel ironic twist, the files named '-r' and '-f' are preserved.
But the problem is actually made worse by the fact that most command line parsing libraries allow flags to be condensed into a single option (like -r -f can be condensed into -rf).
GNU utilities do this by default. This coupled with expanding * turns ANY file that starts with a leading - into a potential source of doom.
So, imagine that you have a file named '-truffle' in there somewhere. rm * expands to 'rm -truffle [your files]'. That is interpreted by rm as "rm -t -r -u -f -f -l -e [your files]" (note the presence of '-r' and '-f').
Gasp and horror!
However, your salvation is that rm halts if it encounters an unknown option (like -u). You can wipe your brow and sigh in relief, because you just dodged a bullet.
IIRC, the Unix haters handbook dedicates a whole chapter to these types of landmines, and the "funny" thing is that most of it still applies, about two decades after it was written.
But seriously, that's an accident waiting to happen. Like a less knowledgeable user trying to delete a file named *
And there are some really awful things you can do by abusing shell expansion. Like this example (WARNING: DON'T BLINDLY RUN THESE!).
Go to a directory with non-important files, and do:
Since there's a good chance that all of your files have sensible names (that is, they don't start with weird symbols), that will expand to: Oops. Kiss your files AND directories goodbye. That includes write protected files that would give rise to a warning if you tried to remove them. And in a cruel ironic twist, the files named '-r' and '-f' are preserved.But the problem is actually made worse by the fact that most command line parsing libraries allow flags to be condensed into a single option (like -r -f can be condensed into -rf).
GNU utilities do this by default. This coupled with expanding * turns ANY file that starts with a leading - into a potential source of doom.
So, imagine that you have a file named '-truffle' in there somewhere. rm * expands to 'rm -truffle [your files]'. That is interpreted by rm as "rm -t -r -u -f -f -l -e [your files]" (note the presence of '-r' and '-f').
Gasp and horror!
However, your salvation is that rm halts if it encounters an unknown option (like -u). You can wipe your brow and sigh in relief, because you just dodged a bullet.
IIRC, the Unix haters handbook dedicates a whole chapter to these types of landmines, and the "funny" thing is that most of it still applies, about two decades after it was written.