- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If you have a python, everything looks like a mouse at frist.
Admin
I did the Windows and cmd script equivalent to this sort of thing quite a lot back in day (25-30 years ago). I can't rememeber if it was genius or madness (or just neccesity). I would have to send the robot to fetch and load that backup tape into my memory ... and I don't know if its been kept in nice enough conditions to survive :-). Plus the robit has a tendency to just slam the tape not QUITE in the slot... LOL.
Admin
I'm going to rule out "one of the best", just from that sentence alone.
Admin
"If I just do it in bash, if the first command fails, the second command doesn't run."
You have to use the -e option with bash for this behavior. The default is for bash to continue.
As far as the best or the worst programmer... He wrote code that does what he wants it to do. That makes him a good coder.
Admin
Maybe I'm misunderstanding something but this doesn't seem like a WTF. The way it reads it sounds like these are personal scripts for the dev and not something the dev writes for others to use. The dev is correct about a lot of the points.
Of course, all of this goes out the window if other devs have to use these scripts.
Admin
but since shell=True is set on run(), these are more or less shell/bash scripts, he even uses shell features ($()).
So, don't tell him, but he knows and uses shell/bash.
Admin
I totally agree.
For personal dev scripts, there is only one rule: If it works, then it works.
Admin
The way I read it, that's kind of the point. It's a bash script running from Python, but he "doesn't know bash".
Admin
I don't see any bashisms so far, so it's just sh (if $SHELL is not really bash, but ye olde paine sh, or maybe dash, or something else sh-like), making the thing more portable if needed - in his case, just python is a dependency on the target system. So "Ernest was either the worst developer he was working with, or one of the best." maybe can be answered with YES.
Admin
I once inherited a C program that did stuff like
Somehow it just felt worse seeing it in C than in Python.
Admin
Actually
exec? I ask this because "exec" isn't a POSIXy function. It's a family of wrappers around "execve", normally, so its presence here indicates that the original author of the code wrote it, and I wouldn't be surprised to learn that this "exec" is just a wrapper around a call to "system". (None of the exec family functions takes a command line. They all take an array of argv[]s, and possibly an array of environment variable strings.)It's also a bit of a shame if
srcordstis a string containing; malicious_command ;...Admin
What? He noticed a flaw that he personally had an used the computer to address it. That's exactly what programming is for! I bet you don't like static typing either :p
Admin
Agree.
"Aankhen" really needs to learn to keep his nose out of people's personal tooling.
Admin
I use
maketo handle such things. Amake pushdoes all the necessary file creation and image building required and pushes the image for example.Works quite nicely. Especially if you have to generate for example some intermediary files from sources, where the intermediary file goes to the docker image.
Yeah, yeah. I know. I'm old-fashioned.
Admin
So wait, this guy wrote a short and quick script that gets him to a desired state and instead of being praised for it some fool suggest he learn a new language, new library and rebuild that script as an entire program?
Now that's a wtf.
Admin
Aankhen didn't understand that, when Ernest said that his code handled errors, he meant that it handled errors exactly the way he wanted, which was NOT AT ALL. His code was simple, it did exactly what he needed AND it was not meant to be used or maintained by anyone else. Why would anyone have to take issue with it?
I have to admit that, if there is a WTF among them both, it is with Aankhen.
Admin
It's not a short and quick script compared to the shell. The shell script for this is literally the two strings passed to
subprocess.runconcatenated with a line separator between them.For example
Admin
You can even leave out the #! and it will still work perfectly well if you only care about running the script in the shell you're currently using.
Admin
And yet it is short and quick in absolute terms. It does the job. And most importantly it's done in a way that's familiar to its creator.
A good engineer does not chase perfection. Nor do we settle for good enough. Good enough IS the end goal.
Admin
Rick, he's basically written a bash script with extra steps. I have to regard him as a mediocre to poor coder (I lean mediocre, because the code does do its job and account for side-effects well enough), because this kind of comfort-zone logic suggests that he is not very good at learning new things and using the right tools for the job. I'm all for hackish solutions to problems and getting clever with code in ways that your tools weren't intended to be used if it does the job well, but evidence of not being a good learning animal and resorting to unnecessarily inefficient problem-solving is a bad sign in coders when coding ought to be a creative, problem-solving profession where you figure new things out and try to make it run quickly and smoothly.
Admin
And that's all fine and well if you have the time and budget to bother with that sort of thing. Some times you just want to hack together a tool quickly and make it work so that you can get on with the job people are actually paying you for.
You can't put "making my private helper tool more efficient and better" on your time sheet. Well, you can. Once.