[Portland] [Patch] Portability and Xfce

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Mon Apr 24 22:21:43 EEST 2006


Kevin Krammer wrote:
>>>>The Makefile also does some problematic things like "head -n-1", which
>>>>is not supported everywhere. The synopsis part can be replaced with
>>>>"grep -v ^Synopsis", not sure about the "(read;read;...;head -n-1)" one.
>>>
>>>Not sure about this. Can you provide a patch for this as well?
>>
>>See attachment. Should produce the same result.
> 
> Applied, thanks again.
> 
> Do you think you could come up with a patch the extracts the examples as well?
> I'd like to have them in the output for --help
> 
> The code in the script should be similar to the one for usage, very likely 
> only copy & paste once the extracted text is available.

See attached AWK script (with comments), just add the script to the
repository (doesn't need to be installed) and change the line in
Makefile.in to invoke the script to generate the *.usage files. I guess
stuff will get to messy when adding more sed magic to the Makefile, and
awk is way more readable than sed. ;-)

> Cheers,
> Kevin

Benedikt
-------------- next part --------------
#!/usr/bin/awk -f
#---------------------------------------------
#
#   extract-usage.awk
#
#   Simple AWK script to extract the usage text from the description.
#
#   Copyright 2006, Benedikt Meurer <benny at xfce.org>
#
#   LICENSE:
#
#   Permission is hereby granted, free of charge, to any person obtaining a
#   copy of this software and associated documentation files (the "Software"),
#   to deal in the Software without restriction, including without limitation
#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
#   and/or sell copies of the Software, and to permit persons to whom the
#   Software is furnished to do so, subject to the following conditions:
#
#   The above copyright notice and this permission notice shall be included
#   in all copies or substantial portions of the Software.
#
#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
#   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
#   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
#   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
#   OTHER DEALINGS IN THE SOFTWARE.
#
#---------------------------------------------

BEGIN {
	# set to 1 when the current line should be printed
	print_current_line = 0
}

/^Description/ {
	# "Description" ends the synopsis, and should
	# not be included in the usage text
	print_current_line = 0
}

/^Examples/ {
	# "Examples" starts the examples section, and
	# should be included in the usage text
	print_current_line = 1
}

{
	# print this line only if print_current_line is 1
	if (print_current_line > 0)
		print $0
}

/^Name/ {
	# "Name" starts the synopsis section, but "Name"
	# itself should not be included in the usage
	print_current_line = 1

	# also skip the empty line after "Name"
	getline
}



More information about the Portland mailing list