--- mmap_flags.sh~	2023-12-27 20:41:23.859114015 +0000
+++ mmap_flags.sh	2023-12-27 21:16:57.577904419 +0000
@@ -10,7 +10,17 @@
 	arch_header_dir=$2
 fi
 
-arch_mman=${arch_header_dir}/mman.h
+export arch_mman=${arch_header_dir}/mman.h
+
+if [ x != "x$header_dir" ] ; then
+   export header_dir="$header_dir";
+fi
+if [ x != "x$arch_header_dir" ] ; then
+   export arch_header_dir="$arch_header_dir";
+fi
+if [ x != "x$linux_mman" ]; then
+   export linux_mman="$linux_mman";
+fi
 
 # those in egrep -vw are flags, we want just the bits
 
@@ -20,16 +30,19 @@
 (egrep $regex ${arch_mman} | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
-egrep -q $regex ${linux_mman} && \
-(egrep $regex ${linux_mman} | \
+if [ x != "x$linux_mman" ]; then
+   egrep -q $regex ${linux_mman} && \
+      (egrep $regex ${linux_mman} | \
 	egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+fi
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
 (egrep $regex ${header_dir}/mman-common.h | \
 	egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
 (egrep $regex ${header_dir}/mman.h | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
