Useless Use of While-Read-Echo Award



  • I just logged on to a system of one of my previous employers (to which I still legally have access) - and had to slam my head to the desk when I found what they did to a script I wrote

    Original line:

                           PATH=$scriptpath:$PATH pracct-readlog "$user"

    which is a shell script I wrote that reformats the log file for printing a bit, and filters out items not for that user. Now behold what they have made of this line:

                           cat ${user}.log |while read line; do echo "${line}"; done

    It is nice that they now use user specific log files - it slightly increases performance. However, can anyone tell me what the while loop is for? Hint: the log file does NOT contain backslashes the "read" command may interpret.

    Looks like someone found a way to evade the Useless Use of Cat Award...

     

    There were also some other new WTFs in that script (like, some removed security check, so every user can now request everyone's log easily)... but that's besides the point of this post :P



  • @OperatorBastardusInfernalis said:

    However, can anyone tell me what the while loop is for?
     

    I am going to guess that they wanted to remove leading whitespace from each line of the logfile? 



  • There is no leading whitespace :P



  •  Erm... maybe he's practising his pipes. Or he originally had put somethig in front of each line. Or it's a fiendish plot to annoy you.

    Btw this forum is getting to me. I glanced at firefox's progress bar and for a second I thought it said 'Sending teh request to..."



  • That's still not evading a UUOCA. The cat there is useless... you can just redirect the while loop.



  • You are right, I missed that. Makes it even more of a WTF...


Log in to reply