Conversation with an Onshored Offshore Idiot



  • We use a ksh script (owned by another team) that takes several arguments, the last of which is an optional "descriptive notes" field. If you pass anything that starts with a dash as the final argument, it causes a known bug in the script to cause it to exit. Simple solution? Don't pass a leading dash. Enter our hero. He attempts to use it as follows:

    #!/bin/ksh
    TheParams="$*"
    theScript "arg1" "arg2" ... "${TheParams}"

    The problem is that if his script was called with any options (eg: -d), theScript would fail.

    The following conversation ensued:

    Me: Don't pass the command line options: the leading dash causes known problems that crash it
    Idiot: What shall I do?
    M: Either omit, or pass the last argument as a blank string
    I: Changes it to: ${TheParams}
    M: No, leave the quotes, remove the contents
    I: Changes it to: "\$\{TheParams}"
    M: No, just delete everything between the quotes, leaving just the quotes
    I: Changes it to: "${TheParams} (no trailing double quote)
    M: Reaches over him and enters the correct string
    I: Oh?
    How do these people manage to fill out their passport applications? 
     


  • @snoofle said:

    We use a ksh script (owned by another team) that takes several arguments, the last of which is an optional "descriptive notes" field. If you pass anything that starts with a dash as the final argument, it causes a known bug in the script to cause it to exit. Simple solution? Don't pass a leading dash. Enter our hero. He attempts to use it as follows:
    #!/bin/ksh
    TheParams="$*"
    theScript "arg1" "arg2" ... "${TheParams}"

    Um,


    #!/bin/ksh

    theScript "arg1" "arg2" ... #"$*"

    HTH.  HAND

    (If you actually *want* the last argument to be passed, you can always use a ':' or other innocuous leading character so that the first character will never be a dash.  But, when you say 'optional', I assume you mean 'optional', and therefore 'not necessary'.  Putting the leading # might go over better with this guy, as he may not quite recognize what it does at that position.)

    For what it's worth, the answer to your confusion is that the individual in question was not trying to do what you told him, but rather trying to fix the program.  It was obvious to him that your solution would discount the arguments - which he wanted to put into the descriptive notes.



  • @tgape said:

    @snoofle said:
    We use a ksh script (owned by another team) that takes several arguments, the last of which is an optional "descriptive notes" field. If you pass anything that starts with a dash as the final argument, it causes a known bug in the script to cause it to exit. Simple solution? Don't pass a leading dash. Enter our hero. He attempts to use it as follows:

    #!/bin/ksh
    TheParams="$*"
    theScript "arg1" "arg2" ... "${TheParams}"

    Um,

    #!/bin/ksh

    theScript "arg1" "arg2" ... #"$*"

    HTH.  HAND

     

    #!/bin/ksh
    TheParams="$*"
    theScript "arg1" "arg2" ... "${TheParams#-}"

    No?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.