Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I get why that seems silly, and I write shell all day (for provisioning Vagrant machines where I don't need Puppet. I'm still yet to work Ansible properly...), so I know exactly what that command does.

But to some of my coworkers who don't write shell very often at all, it would make the script far clearer (which is useful as they need to be able to edit it on the fly) to those who don't know shell



Encouraging coworkers to learn the proper syntax seems a better choice than hiding it with personally chosen abstractions (albeit more readable).


I don't disagree, but in some contexts that trade off is worth it, in my opinion.


You should strive for better readability for intended audience in every single program you write. It's like writing prose, really. It's ok to write "notes to self" with words shortened to single letters and strange symbols all around the place. It's not ok to do the same in a report from a meeting.

You should always remember who you're writing for and write accordingly. Hint: you almost never write for the computer.


Yeah, definitely better to keep it idiomatic. Also:

$ test -f "$file"

is pretty clear I think.


The "proper" syntax is dumb. I've never considered writing functions to get around it, but seeing this makes me want to contribute some builtins to bash.


The correct answer. ^^^


Then just use test instead.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: