commit 2bfd0b1

Randy Palamar  ·  2024-01-02 21:13:25 +0000 UTC
parent c2cc522
replace tail component of src with srcsection in man()

This is useful when man() is called with the optional 'section'
parameter and can be used to replace components such as '.nro'
with a '.(section)'.
1 files changed,  +2, -2
+2, -2
 1@@ -489,10 +489,10 @@ function man(srcs, section)
 2 		if not src:match('^[$/]') then
 3 			src = '$srcdir/'..src
 4 		end
 5+		local srcsection = section or src:match('[^.]*$')
 6 		local i = src:find('/', 1, true)
 7-		local gz = '$outdir'..src:sub(i)..'.gz'
 8+		local gz = '$outdir'..src:sub(i):gsub('[^.]*$', srcsection)..'.gz'
 9 		build('gzip', gz, src)
10-		local srcsection = section or src:match('[^.]*$')
11 		file('share/man/man'..srcsection..'/'..gz:match('[^/]*$'), '644', gz)
12 	end
13 end