4 ms·
First off, the name "resize" has the semantics of "take this action". The "make this so" version would be: size 500G file I think you're effectively aski
by eevilspock 5y ago
First off, the name "resize" has the semantics of "take this action".
The "make this so" version would be:
size 500G file
I think you're effectively asking, "Should an individual CLI command be imperative or declarative?"[1] I think when possible, declarative is superior.
Whether an error should be returned is a separate question. In the declarative "make this so" version, you would not return an error if the file were already 500G (ideally it would not mutate the file).
But in the imperative "take this action" version, it depends on the intended semantics of the imperative command. Compare `mkdir` (see tacostakohashi's comment) and `chmod`. In some cases you just need to know that you have what you wanted (chmod), and in others you might need to know if an actual occurred (mkdir).
---
[1]: You might think the question to be imperative vs functional. I'm not an expert, but I'm pretty sure purely functional programming is a subset of declarative programming that involves first class and higher order functions. I don't know of any CLI shell environments that support that. At the very least, though, a functional version of `size 500G file` would not change the state of the file system, and would instead "return" a 500G version via stdout.