Brad Fitzpatrick (brad) wrote,
Brad Fitzpatrick
brad

sh is ugh

I know people say Perl looks ugly, but man...

From OpenIPMI's bmclanconf:
hex_to_ip ()
{
    test $# -ge 1 || return;
    local HEX B1 B2 B3 B4;
    HEX=`echo $1 | tr '[:lower:]' '[:upper:]'`;
    H1=`echo $HEX | cut -c1-2`
    H2=`echo $HEX | cut -c3-4`
    H3=`echo $HEX | cut -c5-6`
    H4=`echo $HEX | cut -c7-8`
    B1=`echo 10 o 16 i $H1 p | dc`
    B2=`echo 10 o 16 i $H2 p | dc`
    B3=`echo 10 o 16 i $H3 p | dc`
    B4=`echo 10 o 16 i $H4 p | dc`
    echo "$B1.$B2.$B3.$B4"
}

Not sure if I should be impressed or disgusted. Kinda my reaction when I see anything done in a shell.

I used to complain about TCL, but shell scripts piping things into new programs left and right... is that anywhere near efficient? Or does it come down to just not mattering? I suspect.

IPMI is frickin' awesome, though.
Tags: perl, tech
Subscribe

  • Ukraine

    Nobody reads my LiveJournal anymore, but thank you to everybody in Russia protesting Putin's insane war against Ukraine. (I know it's risky…

  • Happy Birthday!

    Happy 20th Birthday, LiveJournal! 🐐🎂🎉

  • hi

    Posting from the iPhone app. Maybe I'm unblocked now.

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 5 comments