SUSE Conversations


ATT Live 2012 Session Spotlight–Bash Debugging



By: dcoughanour

March 5, 2012 3:09 pm

Reads:366

Comments:0

Rating:0

Note: To see a list of all the sessions planned for ATT Live 2012, go to http://www.novell.com/training/attlive/sessions.html.

To give you a taste of the learning you can expect to experience at ATT Live 2012, over the next month or so, I’ll be posting as many session spotlights as I can. This first Session Spotlight post, on Bash Debugging, comes from Brandon Heaton (see Brandon’s bio at the bottom).

His reason for creating this session is, “Automation with Bash is an essential skill for Advanced System Administrators. As your scripts grow in size and complexity, advanced debugging becomes more essential to managing your large project code.”

Here’s one of the topics Brandon is going to present in the Bash Debugging session:

Want to know a simple and effective insider secret for Bash debugging? Just add the following alias to your ~/.bashrc file, and Bash debugging becomes that much easier (as does debugging of Tcl, C, Python, etc.):

#------------------------------------------------------------------------------
alias pvi.sh="vim -c 'let g:sh_fold_enabled=7' -c ':set fdm=syntax' -c 'sy on'"
#------------------------------------------------------------------------------

Enter “source ~/.bashrc” at the command line.

Then, rather than launching your Bash editing session like this…
“vi myscript.sh”

…launch it with your new alias instead:
“pvi.sh myscript.sh”

You’ll notice that folding is turned on and automatically folds your functions and control structures.

You’ll also notice that syntax hi-lighting is turned on, which is a key feature for debugging code.

Not sure why you are getting an error? In your “pvi.sh” session, jump to the line showing the error and look at the coloring and placement of code, based on the syntax hi-lighting. For example, if all your code in that region is red (but shouldn’t be, based on the syntax) there is good chance that a closing quote is missing in the code. Perhaps it is a missing closing control structure reserved word, etc.

Syntax hi-lighting is available with the default vi (Vim) that ships with SUSE Linux Enterprise 11 (desktop and server), and is just one of several Bash debugging techniques taught at ATT Live this year.

Hope to see you in Vegas in March! There is going to be a lot of excellent instruction and exciting innovations in SUSE Training and Certification.

P.S. If you’re looking for good XML editing for your Autoyast XML files, try this Vim alias on for size (best raw XML editing method I have yet seen):

#-------------------------------------------------------------------------------
alias pvi.xml="vim -c 'let g:xml_syntax_folding = 1' -c ':set fdm=syntax' -c 'sy on'"
#-------------------------------------------------------------------------------

The built-in help for Vim will tell you more about “folding” to get you started in editing code, tags, visual blocks, etc.

Enjoy!

Brandon Heaton’s Brief Bio:
————————————–

  • 15 years working with Linux and Windows from the data center to the workstation
  • Unix DB Admin for 5+ years prior to Novell
  • 9 years working for Novell: 3 years in Technical Support, 6 years in Training Services
  • Training services Subject Matter Expert and Data Center Engineer, with strong focus on:
    • SUSE Linux Enterprise Server and Desktop
    • Enterprise Bash Programming
    • High Performance Administration (HPA)
    • SUSE Architecture and Deployment
    • Technical Training Design, Development and Delivery
    • Windows Workstation Optimization
  • I created and maintain an Open Source HPA Project released by Novell called “Mooty”
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Tags: , ,
Categories: SUSE Linux Enterprise Server, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

Comment

RSS