IBM DeveloperWorks has published a tutorial on the “Shell Curses” library of cursor-manipulation script functions for shell programmers. Written by Dana French, the creator of Shell Curses back in 1993, this intermediate-level tutorial explains the library's terminal functions, and provides tips and code samples for writing typical scripts.
Much like the “C” language “Curses” library, Shell Curses enable programmers to perform text-based cursor movements to specific screen locations, says French. The library enables shell programmers to create menuing and data-entry systems without the need to use compiled binaries.
In recent years, says French, knowledge of Shell Curses has faded among UNIX administrators due to the improvements in graphical interfaces. Yet, “the need still exists for these functions,” he argues. For example, they are an efficient way to write Bash shell scripts that have menus and do input-entry validation or for creating front-ends for installation systems, databases, and other menuing programs. The syntax is similar to “C” Curses, says French, but Shell Curses offers the advantage of not requiring compilation.
In the tutorial, French describes each of the functions, as well as “enhanced” functions such as getwd (retrieve one word from standard input). He then provides code examples and offers tips such as how to overcome a common glitch when using Shell Curses with IBM AIX, and how to decide when to use a function library vs. including a file as a “dot” script.
This article was originally published on LinuxDevices and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.