6 ms·
Changing the default behavior of a standard posix command is a footgun. It would have been better to rename it.
by bb88 7y ago
Changing the default behavior of a standard posix command is a footgun. It would have been better to rename it.
- titzer 7y ago> It would have been better to rename it. Maybe. It's worthwhile pointing out that "mv x" with no second argument is an error: mv: missing destination file operand after 'x' Try 'mv --help' for more information. I also don't have the habit of letting people type in my shell, so there's that. TBH I really don't understand the level of pedantry (and frankly, sheer outrage) in this thread at all. It sucks to be on the receiving end of such disapproval over something so trivial. Let this person do what they want! It's a neat little hack. It also inspired me to see what more I could do with 'read'--something I have ignored for 20 years.
- bb88 7y ago$ mv --help Usage: file [OPTION...] [FILE...] Determine type of FILEs. So mv --help now returns the help for the `file` command. You're right, that's not worth warning people at all. God help any user that's on a shared system whose sysadmin thinks this is a good idea putting in the default /etc/profile. To be fair, I don't feel like I'm being pedantic. I'm anti-footgun.
- titzer 7y ago> sysadmin thinks this is a good idea putting in the default /etc/profile Well that, I agree, would be dumb.
- kilpikaarna 7y agoYou could just filter out anything that begins with a dash and pass it to mv. It seems like mv always interprets that as an option anyway, even if you have a file named --help or whatever. I like this kind of thing! Minimal code but very elegant from a UX perspective. The oh but you could just mv foo-{bar,baz}.txt crowd is completely missing the point.
- bb88 7y agoI love bash. I love unix/linux. I love that bash gives you that kind of power. I love the fact that he figured out a nifty way of doing this. But please please please please with all the love of America, baseball, and apple pie, don't change the default behavior of basic unix commands. Otherwise you force people into writing nonsense like this: MV=/usr/bin/mv ${MV} ${FILE1} ${FILE2}
- kelnos 7y ago> The oh but you could just mv foo-{bar,baz}.txt crowd is completely missing the point. I disagree. I think a better way to think about things is, "can I accomplish my goal most of the time using the standard tools without writing something custom?" I'll be the first to admit that there are a ton of things in the shell and in coreutils that I don't know about. I bet I've written several scripts over the years with custom functionality that could be replaced with standard tools I didn't know about. That's the thing that I want to avoid.
- kelnos 7y ago> (and frankly, sheer outrage) I think you're reading way too much into what I and others are saying. Honestly I'm finding being misunderstood and mis-characterized as angry to be the only thing that's bothering me.
- Certhas 7y agoThat's a valid constructive critique. The people who are saying it's not necessary because they prefer alternative ways of interacting with their machine are not arguing that though. The bit the parent replied to was actually claiming that there is no valid reason to do things this way (with a minor bash script) because there are other ways (slightly mysterious curly braces hacks) that do something similar in some cases... which is just, bizarre?
- kd5bjo 7y ago'Godel_unicode > That's not to say someone can't think of a reason for it, but rather that there are better ways to do what it does. 'Certhas > The bit the parent replied to was actually claiming that there is no valid reason to do things this way … because there are other ways … that do something similar It appears to me that you're reading more into 'Godel_unicode's comment than was written. Something not being necessary does not preclude it being useful, and I haven't seen anyone imply otherwise except for you¹. Working through the double-negative, 'Godel_unicode even explicitly acknowledges that some people may have a reason to do things this way, despite their opinion that it's inferior to their method. ¹ I haven't studied the entire thread, so it's likely I've missed someone's comments.
- Certhas 7y agoI read it as: You can think for a reason to do X but doing Y is strictly better, so your reason is invalid. I'm pretty sure what the comment doesn't say, also in tone, is something like: Here are two options, X and Y, sometimes you might prefer one, sometimes the other. Specifically look at the comment that Godel_unicode is disagreeing with. That comment points out that some people might prefer the other solution X for their own reason. The way I read it, Godel_unicode replies that the person who is not using Y is "not thinking things through", and is ignoring infinitely many reasons ("The reasons go on forever.") to do Y. Even though you can come up with "a reason" for X the infinitely many reasons for Y clearly beat it, and thus Y is just objectively better. Maybe the comment was intended more charitably than I read it.
- 7y ago