- 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
Not surprised he passed on it, it's broken.
Admin
That code has the weirdest fencepost error I've ever seen. I can understand getting 0-indexed and 1-indexed arrays backwards, but why would you ever expect a 2-indexed array?
Admin
And he could've reduced it to a single line:
file="$(printf '%s,' "$WORKSPACE/ewprd"{1..118}"_$DATECODE.dmp" | head -c -1)"
Admin
It was initialised with the 1 file
Admin
Nice use of head to remove the trailing comma
Admin
And since there is no
$i_
variable, we want this:Admin
my eyes...
Admin
file=$( jot -w $WORKSPACE/ewprd111_$DATECODE.dmp 118 | tr -s \n , | sed -e 's/,$//')
note: cut -c didn't work for me, not a linux box. {1..118} didn't work, not running bash. very very plain-vanilla bsd environment.
Admin
So you are from the "comma is the terminator" camp.
Or are you from the "comma is the begin marker" camp?
Either way, you are definitely not from the "comma is the separator" camp, and you hate
Admin
comma comma comma chameleon, you come and go, you come and goooo.
Admin
not sure what camp he's from, but you're certainly from the 'I don't bother reading all the code' camp.
Admin
And I respect you for managing to find time to carefully studying all the code that is presented on TDWTF. You surpass most of us who very selfishly only read the codez as long as they entertain us and skip the rest.
Admin
@eth0: You seem very certain of which language or shell the code is written to. And don't forget this was running back in 2008, not in 2019. Was the {range} notation available way back then?
I know I don't know. Perhaps you do.
Admin
My first job out of college I worked primarily with a couple friends I went to school with. I was used to competence in programming with these guys. Second job, I got to discover how bad things got. One cow-orker came to me with 2 printed pages of a function he was writing and he wanted help figuring out what was wrong with it. I asked "what does it do?" He started explaining the code line by line. I stopped him and asked "20 words or less: what is this supposed to do?" The question seemed to shock him, but he thought about it and said "it's supposed to convert a string date to 3 integers with month, day and year." I asked, "are the inputs always sanitized? That is, 3 pairs of digits with a slash between?" He said it was. I scribbled a quick sscanf in the corner of his listing. "Try that instead." He came back a few minutes later saying it was working. I just shook my head. 2 pages of code. oy!
Admin
,,,,againyou,goyou,go
Admin
Even in 2008 file and FILE were two different variables.
Admin
The script was rejected because it doesn't work. Consider
ewprd117_$DATECODE.dmp
-- It is in the$WORKSAPCE
folder instead.