Explanation of edprofile

The Section Changing Command Options with edprofile gives an overview of this script. Here is the edprofile script (you might want to open it in a separate browser window). To install it, see the Section Programs in This Book's Archive.

The command line parsing happens in several steps. After checking for a leading -v option and being sure that there are more arguments, a for loop stores all arguments until it finds an argument with double dashes ( -- ). The rest of the arguments will be message pathnames that xmh adds to all the commands that are run with XmhShellCommand() -- edprofile doesn't need these pathnames, so the script ignores them.

After the script finds the profile entry to edit, it starts the ed editor to do the job. ed isn't very helpful about telling you when there have been errors. The command ed - cancels all ed output except error messages (which are often just a question mark, ?). The script saves ed output in the errs shell variable and saves ed exit status, too. If $errs isn't empty or the ed exit status is not 0, an error is printed and the script quits. Otherwise, verbose information is printed if the -v switch was used.