texlive[73677] trunk: pdfjam (1feb25)

commits+karl at tug.org commits+karl at tug.org
Sat Feb 1 21:49:38 CET 2025


Revision: 73677
          https://tug.org/svn/texlive?view=revision&revision=73677
Author:   karl
Date:     2025-02-01 21:49:38 +0100 (Sat, 01 Feb 2025)
Log Message:
-----------
pdfjam (1feb25)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam
    trunk/Master/texmf-dist/doc/man/man1/pdfjam.1
    trunk/Master/texmf-dist/doc/man/man1/pdfjam.man1.pdf
    trunk/Master/texmf-dist/doc/support/pdfjam/README.md
    trunk/Master/texmf-dist/scripts/pdfjam/pdfjam
    trunk/Master/tlpkg/libexec/ctan2tds

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.1
    trunk/Master/texmf-dist/doc/support/pdfjam/zsh/
    trunk/Master/texmf-dist/doc/support/pdfjam/zsh/_pdfjam

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.00

Modified: trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam	2025-02-01 20:43:20 UTC (rev 73676)
+++ trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam	2025-02-01 20:49:38 UTC (rev 73677)
@@ -1,5 +1,5 @@
 #!/bin/sh
-version=4.00
+version=4.1
 #########################################################################
 ##                                                                     ##
 ##  pdfjam: A shell-script interface to the "pdfpages" LaTeX package   ##
@@ -101,7 +101,7 @@
 	value="$1"
 	case "$value" in
 	\{*\}) ;;
-	*,* | *\]*) value="{$value}" ;;
+	*,* | *=* | *\]*) value="{$value}" ;;
 	esac
 	printf %s "$value"
 }
@@ -113,6 +113,40 @@
 	esac
 	printf %s "$value" | sed -E 's/([0-9]{1,}\.{0,1}[0-9]*)(,|$)/\1bp\2/g'
 }
+## Check whether string contains only harmless characters
+is_harmless() {
+	printf %s "$1" | grep -q '^[A-Za-z0-9.-]\+$'
+}
+##  Validate pagespec syntax
+is_valid_pagespec() {
+	# P = [0-9]*|last  is any or no page
+	# P(-P)?  is any or no page range (the latter being an implicit empty page)
+	# (P(-P)?|\{\})  is any page range or an implicit or explicit empty page
+	# (,(P(-P)?|\{\}))*  is any list of page ranges and empty pages separated by and beginning with a comma
+	printf %s ",$1" | grep -qE '^(,(([0-9]*|last)(-([0-9]*|last))?)|\{\})*$'
+}
+##  Get appropriate file extension if input is supported
+get_extension() {
+	extension=
+	if test -n "$checkfiles"; then
+		case "$(file -Lb "$(realpath -- "$1")")" in
+			'PDF document'*) extension=pdf ;;
+			'PostScript document'*) extension=eps ;;
+			'JPEG image data'*) extension=jpg ;;
+			'PNG image data'*) extension=png ;;
+		esac
+	elif test -f "$1" && test -r "$1"; then
+		case "$1" in *.*)
+			case "$(printf %s "${1##*.}" | tr A-Z a-z)" in
+				pdf) extension=pdf ;;
+				jpg|jpeg) extension=jpg ;;
+				png) extension=png ;;
+				ps|eps) extension=eps ;;
+			esac
+		esac
+	fi
+	[ -n "$extension" ] && echo "$extension"
+}
 ##
 ##  Define a function to output verbose comments:
 ##
@@ -188,8 +222,13 @@
 if [ -z "$pdfinfo" ]; then pdfinfo="not found"; fi
 iconv=$(command -v iconv)
 if [ -z "$iconv" ]; then iconv="not found"; fi
+##  Sanity check the 'file -Lb' utility to identify files if it works;
+##  rely on the file extension otherwise.
+case "$(file -Lb "$0" 2>/dev/null)" in
+	'POSIX shell script'*) checkfiles=checkfiles ;;
+	*) checkfiles=
+esac
 ##
-##
 ##  Defaults
 ##
 outFile="$pwd"      ##  Output to the current working directory
@@ -196,9 +235,6 @@
 suffix=pdfjam       ##  Default filename suffix to be used when
 ##                      --outfile is either (a) a directory, or (b)
 ##                      not specified in a --batch call.
-checkfiles=         ##  Don't use the Unix 'file -Lb' utility to
-##                      identify PDF files from their contents;
-##                      rely on the .pdf or .PDF extension instead.
 keepinfo=           ##  Don't try to preserve "pdfinfo" data
 landscape=          ##  Use portrait./Do not switch width and height.
 twoside=            ##  No "twoside" option to documentclass
@@ -310,194 +346,191 @@
 https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
 
 Usage: pdfjam [OPTIONS] [--] [FILE1 [SEL1]] [FILE2 [SEL2]]...
-where
-* 'FILE1' etc. are PDF files (JPG and PNG files are also allowed).  For
-   input from /dev/stdin, use the special name '/dev/stdin' in place of any
-   of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to
-   allow input through a pipe (note that if /dev/stdin is connected to tty,
-   an error results).  If 'FILE1' is absent, pdfjam will use '/dev/stdin'
-   (and will use '-' for the page selection -- see next item).
-* 'SEL1' is a page selection for FILE1, etc.
-   To select all pages (the default) use '-'.  See the pdfpages manual for
-   more details.  An example:
-          ... file1 '{},2,4-6,9-' ...
-   makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages
-   9 onwards (up to the end of file1).
-   A page selection can be applied to more than one file, e.g.,
-          ... file1 file2 file3 1-7 ...
-   applies page selection '1-7' to all three files; but for example
-          ... file1 file2 2- file3 1-7 ...
-   would apply the page selection '2-' to file1 and file2, and '1-7'
-   to file3.  A page selection applies to all the files *immediately*
-   preceding it in the argument list.  A missing page selection defaults to
-   '-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets
-   used by default.
-* 'options' are pdfpages specifications in the form '--KEY VALUE' (see
-   below), or
-     --help  (or -h, or -u)
-                  Output this text only; no processing of PDF files.
-     --configpath
-                  Output the 'configpath' variable and exit immediately; no
-                  processing of PDF files.
-     --version (or -V)
-                  Output the version number of pdfjam and exit immediately; no
-                  processing of PDF files.
-     --quiet  (or -q)
-                  Suppress verbose commentary on progress.
-     --batch
-                  Run pdfjam sequentially on each input file in turn, and
-                  produce a separate output file for each input, rather
-                  than the default behaviour (which is a single run of
-                  pdfjam on all of the input files, producing a single
-                  output document).  For the location of output
-                  files, see '--outfile'.  The --batch option cannot be
-                  used in the case of input from stdin.
-     --outfile PATH  (or -o PATH)
-                  Specifies where the output file(s) will go.  If PATH is an
-                  existing directory, pdfjam will attempt to write its
-                  output PDF file(s) there, with name(s) derived from the
-                  input file name(s) and the --suffix option (see below).
-                  Otherwise the output file will be PATH.  If '/dev/stdin'
-                  is the only or last input file, PATH cannot be a directory.
-                  Your current default PATH for output is:
-                  $outFile
-     --suffix STRING
-                  Specifies a suffix for output file names, to be used when
-                  --outfile is either (a) a directory, or
-                                      (b) not specified in a --batch call.
-                  A good STRING should be descriptive: for example,
-                           --suffix 'rotated'
-                  would append the text '-rotated' to the name of the input
-                  file in order to make the output file name, as in
-                  'myfile-rotated.pdf'.  The STRING must not have zero
-                  length.
-                  [Default for you at this site: suffix=$suffix]
-     --checkfiles
-     --no-checkfiles
-                  If the Unix 'file' utility is available, with options
-                  -L and -b, the output of 'file -Lb FILE1' should be
-                  'PDF document...' where '...' gives version information.
-                  If this is the case on your system you should use
-                  '--checkfiles'; otherwise use '--no-checkfiles',
-                  in which case all input PDF files must have .pdf or .PDF
-                  as their name extension.
-                  [Default for you at this site: checkfiles=$checkfiles]
-     --preamble STRING
-                  Append the supplied STRING to the preamble of the LaTeX
-                  source file(s), immediately before the '\begin{document}'
-                  line.  An example:
-                      pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\
-                          --preamble '\usepackage{fancyhdr} \pagestyle{fancy}'
-                  The '--preamble' option can be used, for example, to load
-                  LaTeX packages and/or to set global options.  If '--preamble'
-                  is used more than once in the call, the supplied preamble
-                  strings are simply concatenated.  For a note on avoiding
-                  clashes, see the README file, also available at
-                  https://github.com/pdfjam/pdfjam
-     --keepinfo
-     --no-keepinfo
-                  Preserve (or not) Title, Author, Subject and Keywords
-                  (from the last input PDF file, if more than one) in the
-                  output PDF file.  This requires the pdfinfo utility, from
-                  the xpdf package, and the LaTeX 'hyperref' package; if
-                  either of those is not available, '--keepinfo' is ignored.
-                  [Default for you at this site: keepinfo=$keepinfo]
-     --pdftitle STRING
-     --pdfauthor STRING
-     --pdfsubject STRING
-     --pdfkeywords STRING
-                  Provide text for the  Title, Author, Subject and Keywords
-                  in the output PDF file.  Requires the  LaTeX 'hyperref'
-                  package.  These options, individually, over-ride --keepinfo.
-     --otheredge
-     --no-otheredge
-                  Rotate every odd page by 180 degrees (or not).  Thus changes
-                  along which edge the pages are flipped in duplex printing.
-     --landscape
-     --no-landscape
-                  Specify landscape page orientation (or not) in the
-                  output PDF file.
-                  [Default for you at this site: landscape=$landscape]
-     --twoside
-     --no-twoside
-                  Specify (or not) the 'twoside' document class option.
-                  [Default for you at this site: twoside=$twoside]
-     --paper PAPERSPEC  (or simply --PAPERSPEC)
-                  Specify a LaTeX paper size, for example
-                  '--paper a4' or simply '--a4paper' for ISO A4 paper.
-                  A wide range of paper sizes is available thanks to the
-                  LaTeX 'geometry' package.  For details see documentation
-                  for LaTeX and/or the 'geometry' package.
-                  If no default value is set and libpaper is not available,
-                  A4 is used.
-                  [Default for you at this site: paper=$paper]
-     --papersize 'WIDTH,HEIGHT'
-                  Specify a custom paper size in points = 1/72 inch (known as
-                  bp in LaTeX and as pt in other software), e.g.
-                      --papersize 612,792
-                  Units may also be specified explicitly, e.g.
-                      --papersize 10in,18cm
-                  [Default for you at this site: papersize=$papersize]
-     --pagecolor RGBSPEC
-                  Specify a background colour for the output pages.  The
-                  RGBSPEC must be a comma-separated trio of integers
-                  between 0 and 255.  An example:
-                         --pagecolor 150,200,150
-                  [Default is no background colour]
-     --tidy
-     --no-tidy
-                  Specify whether the temporary directory created by
-                  pdfjam should be deleted.  Use '--no-tidy' or '--builddir'
-                  below to help debug most errors.
-                  [Default for you at this site: tidy=$tidy]
-     --builddir PATH
-                  Specifies a build directory to be used in place of a
-                  temporary one. Existing files inside will be overwritten.
-     --latex PATHTOLATEX
-                  Specify the LaTeX engine to be used (one of pdflatex,
-                  xelatex, lualatex).  The PATHTOLATEX string must be
-                  the full path to a suitable LaTeX executable (for example
-                  /usr/bin/xelatex on many unix systems).
-                  [Default for you at this site: latex=$latex]
-     --runs N
-                  Run latex N times, for each output document made.
-                  [Default for you at this site: runs=$runs]
-     --vanilla
-                  Suppress the reading of any pdfjam configuration files.
-     --enc
-                  Specify a command-line encoding
-                  [Default for you at this site: enc=$enc]
-     --KEY VALUE
-                  Specify options to '\includepdfmerge', in the LaTeX
-                  'pdfpages' package.  See the the pdfpages documentation
-                  (usually 'texdoc pdfpages') for more information.
-                  Here KEY is the name of any of the many options for
-                  '\includepdfmerge', and VALUE is a corresponding value.
-                  Examples:
-                      --nup 2x1     (for 2-up side-by-side imposition)
-                      --scale 0.7   (to scale all input pages to 70% size)
-                      --offset '1cm 0.5cm'
-                                    (to offset all pages -- note the quotes!)
-                      --frame true  (to put a frame round each input page)
-                      --booklet true (to reorder the pages in signatures,
-                                      generally useful with --nup)
-                      --signature N (specify the signature size, as the
-                                     number of original pages in a signature
-                                     in the final document. Caveat: booklet
-                                     is a short form for signature, so if
-                                     you use booklet true, signature will be
-                                     ignored)
-                      --trim '1cm 2cm 1cm 2cm' --clip true
-                                    (to trim those amounts from left, bottom,
-                                     right and top, respectively, of input
-                                     pages)
-                      --angle NNN (The angle of rotation in degrees. Angles
-                                   that are not either 90, 180 or 270 will
-                                   still create straight rectangular pages,
-                                   only the content will be rotated.)
-                  etc., etc.  For more information see the manual for
-                  the 'pdfpages' package, at
-                  https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
+
+'FILE1' etc. are PDF files (JPG and PNG files are also allowed).  For
+input from /dev/stdin, use the special name '/dev/stdin' in place of any
+of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to
+allow input through a pipe (note that if /dev/stdin is connected to tty,
+an error results).  If 'FILE1' is absent, pdfjam will use '/dev/stdin'
+(and will use '-' for the page selection -- see next item).
+
+'SEL1' is a page selection for FILE1, etc.
+To select all pages (the default) use '-'.  See the pdfpages manual for
+more details.  An example:
+       ... file1 '{},2,4-6,9-' ...
+makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages
+9 onwards (up to the end of file1).
+A page selection can be applied to more than one file, e.g.,
+       ... file1 file2 file3 1-7 ...
+applies page selection '1-7' to all three files; but for example
+       ... file1 file2 2- file3 1-7 ...
+would apply the page selection '2-' to file1 and file2, and '1-7'
+to file3.  A page selection applies to all the files *immediately*
+preceding it in the argument list.  A missing page selection defaults to
+'-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets
+used by default.
+
+'options' are pdfpages specifications in the form '--KEY VALUE' (see
+below), or
+
+  -h, --help
+               Output this text only; no processing of PDF files.
+  --configpath
+               Output the 'configpath' variable and exit immediately; no
+               processing of PDF files.
+  -V, --version
+               Output the version number of pdfjam and exit immediately; no
+               processing of PDF files.
+  -q, --quiet
+               Suppress verbose commentary on progress.
+  --batch
+               Run pdfjam sequentially on each input file in turn, and
+               produce a separate output file for each input, rather
+               than the default behaviour (which is a single run of
+               pdfjam on all of the input files, producing a single
+               output document).  For the location of output
+               files, see '--outfile'.  The --batch option cannot be
+               used in the case of input from stdin.
+  -o, --outfile PATH
+               Specifies where the output file(s) will go.  If PATH is an
+               existing directory, pdfjam will attempt to write its
+               output PDF file(s) there, with name(s) derived from the
+               input file name(s) and the --suffix option (see below).
+               Otherwise the output file will be PATH.  If '/dev/stdin'
+               is the only or last input file, PATH cannot be a directory.
+               Your current default PATH for output is:
+               $outFile
+  --suffix STRING
+               Specifies a suffix for output file names, to be used when
+               --outfile is either (a) a directory, or
+                                   (b) not specified in a --batch call.
+               A good STRING should be descriptive: for example,
+                        --suffix 'rotated'
+               would append the text '-rotated' to the name of the input
+               file in order to make the output file name, as in
+               'myfile-rotated.pdf'.  The STRING must not have zero
+               length.
+               [Default for you at this site: suffix=$suffix]
+  --checkfiles, --no-checkfiles
+               If the Unix 'file' utility is available, with options
+               -L and -b, the output of 'file -Lb FILE1' should be
+               'PDF document...' where '...' gives version information.
+               If this is the case on your system you should use
+               '--checkfiles'; otherwise use '--no-checkfiles',
+               in which case all input PDF files must have .pdf or .PDF
+               as their name extension.
+               [Default for you at this site: checkfiles=$checkfiles]
+  --preamble STRING
+               Append the supplied STRING to the preamble of the LaTeX
+               source file(s), immediately before the '\begin{document}'
+               line.  An example:
+                   pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\
+                       --preamble '\usepackage{fancyhdr} \pagestyle{fancy}'
+               The '--preamble' option can be used, for example, to load
+               LaTeX packages and/or to set global options.  If '--preamble'
+               is used more than once in the call, the supplied preamble
+               strings are simply concatenated.  For a note on avoiding
+               clashes, see the README file, also available at
+               https://github.com/pdfjam/pdfjam
+  --keepinfo, --no-keepinfo
+               Preserve (or not) Title, Author, Subject and Keywords
+               (from the last input PDF file, if more than one) in the
+               output PDF file.  This requires the pdfinfo utility, from
+               the xpdf package, and the LaTeX 'hyperref' package; if
+               either of those is not available, '--keepinfo' is ignored.
+               [Default for you at this site: keepinfo=$keepinfo]
+  --pdftitle STRING
+  --pdfauthor STRING
+  --pdfsubject STRING
+  --pdfkeywords STRING
+               Provide text for the  Title, Author, Subject and Keywords
+               in the output PDF file.  Requires the  LaTeX 'hyperref'
+               package.  These options, individually, over-ride --keepinfo.
+  --otheredge, --no-otheredge
+               Rotate every odd page by 180 degrees (or not).  Thus changes
+               along which edge the pages are flipped in duplex printing.
+  --landscape, --no-landscape
+               Specify landscape page orientation (or not) in the
+               output PDF file.
+               [Default for you at this site: landscape=$landscape]
+  --twoside, --no-twoside
+               Specify (or not) the 'twoside' document class option.
+               [Default for you at this site: twoside=$twoside]
+  --paper PAPERSPEC  (or simply --PAPERSPEC)
+               Specify a LaTeX paper size, for example
+               '--paper a4' or simply '--a4paper' for ISO A4 paper.
+               A wide range of paper sizes is available thanks to the
+               LaTeX 'geometry' package.  For details see documentation
+               for LaTeX and/or the 'geometry' package.
+               If no default value is set and libpaper is not available,
+               A4 is used.
+               [Default for you at this site: paper=$paper]
+  --papersize WIDTH,HEIGHT
+               Specify a custom paper size in points = 1/72 inch (known as
+               bp in LaTeX and as pt in other software), e.g.
+                   --papersize 612,792
+               Units may also be specified explicitly, e.g.
+                   --papersize 10in,18cm
+               [Default for you at this site: papersize=$papersize]
+  --pagecolor RGBSPEC
+               Specify a background colour for the output pages.  The
+               RGBSPEC must be a comma-separated trio of integers
+               between 0 and 255.  An example:
+                      --pagecolor 150,200,150
+               [Default is no background colour]
+  --tidy, --no-tidy
+               Specify whether the temporary directory created by
+               pdfjam should be deleted.  Use '--no-tidy' or '--builddir'
+               below to help debug most errors.
+               [Default for you at this site: tidy=$tidy]
+  --builddir PATH
+               Specifies a build directory to be used in place of a
+               temporary one. Existing files inside will be overwritten.
+  --latex PATHTOLATEX
+               Specify the LaTeX engine to be used (one of pdflatex,
+               xelatex, lualatex).  The PATHTOLATEX string must be
+               the full path to a suitable LaTeX executable (for example
+               /usr/bin/xelatex on many unix systems).
+               [Default for you at this site: latex=$latex]
+  --runs N
+               Run latex N times, for each output document made.
+               [Default for you at this site: runs=$runs]
+  --vanilla
+               Suppress the reading of any pdfjam configuration files.
+  --enc
+               Specify a command-line encoding
+               [Default for you at this site: enc=$enc]
+  --KEY VALUE
+               Specify options to '\includepdfmerge', in the LaTeX
+               'pdfpages' package.  See the the pdfpages documentation
+               (usually 'texdoc pdfpages') for more information.
+               Here KEY is the name of any of the many options for
+               '\includepdfmerge', and VALUE is a corresponding value.
+               Examples:
+                   --nup 2x1     (for 2-up side-by-side imposition)
+                   --scale 0.7   (to scale all input pages to 70% size)
+                   --offset '1cm 0.5cm'
+                                 (to offset all pages -- note the quotes!)
+                   --frame true  (to put a frame round each input page)
+                   --booklet true (to reorder the pages in signatures,
+                                   generally useful with --nup)
+                   --signature N (specify the signature size, as the
+                                  number of original pages in a signature
+                                  in the final document. Caveat: booklet
+                                  is a short form for signature, so if
+                                  you use booklet true, signature will be
+                                  ignored)
+                   --trim '1cm 2cm 1cm 2cm' --clip true
+                                 (to trim those amounts from left, bottom,
+                                  right and top, respectively, of input
+                                  pages)
+                   --angle NNN (The angle of rotation in degrees. Angles
+                                that are not either 90, 180 or 270 will
+                                still create straight rectangular pages,
+                                only the content will be rotated.)
+               etc., etc.  For more information see the manual for
+               the 'pdfpages' package, at
+               https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
 * '--' can be used to signal that there are no more options to come.
 
 Defaults for the options '--suffix', '--keepinfo', '--paper', '--outfile',
@@ -575,13 +608,13 @@
 ##  First note any '--checkfiles' or '--no-checkfiles' option
 ##
 for arg; do
-	case $arg in
+	case "$arg" in
 	--checkfiles)
 		checkfiles=checkfiles
-		callOptions="$callOptions $1";;
+		callOptions="$callOptions $arg";;
 	--no-checkfiles)
 		checkfiles=
-		callOptions="$callOptions $1";;
+		callOptions="$callOptions $arg";;
 	esac
 done
 while test -n "$1$2"; do
@@ -689,6 +722,15 @@
 				otheredge=
 				callOptions="$callOptions --no-otheredge"
 				;;
+			--templatesize)  ##  provide more friendly syntax
+				case "$2" in
+					\{*\}) value="$2" ;;
+					*) value="{${2%%,*}}{${2#*,}}" ;;
+				esac
+				miscOptions="$miscOptions,${1#--}=$value"
+				callOptions="$callOptions ${1} $(enquote "$2")"
+				shift
+				;;
 			--*) ##  miscellaneous options for \includepdfmerge
 				miscOptions="$miscOptions,${1#--}=$(embrace "$2")"
 				callOptions="$callOptions ${1} $(enquote "$2")"
@@ -704,76 +746,35 @@
 	if test "$optionsFinished" = true || test "$argUnmatched" = true; then
 		case "$1" in
 		"" | /dev/stdin)
-			fileSpec="$fileSpec$newline/dev/stdin|awaited"
+			fileSpec="$fileSpec$newline/dev/stdin|unknown|awaited"
 			pageSpecAwaited=true
 			inputFromStdin=true
 			;;
-		-)
-			if test "$pageSpecAwaited" = true; then
-				fileSpec=$(printf %s "$fileSpec" | sed 's/|awaited/|-/g')
-				pageSpecAwaited=false
+		*) ##  All other args should be source files or page selections; if not, we'll quit
+			if ! [ -e "$1" ]; then
+				valid_input=
+			elif extension="$(get_extension "$1")"; then
+				valid_input=input
 			else
-				error_exit "no PDF/JPG/PNG file found at ${1}" \
-					$E_NOINPUT
+				valid_input=path
 			fi
-			;;
-		*) ##  All other args should be PDF (or JPG/PNG)
-			##  source files and page selections; if not, we'll quit
-			if test -n "$checkfiles"; then ## not always available
-				case $(file -Lb -- "$1") in
-				"PDF document"* | "JPEG image data"* | "PNG image"*)
-					##  it's a PDF file (or JPG/PNG) as expected
-					fileSpec="$fileSpec$newline$1|awaited"
-					pageSpecAwaited=true
-					;;
-				*)
-					case ${1} in
-					*.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \
-						*.[jJ][pP][gG] | *.[pP][nN][gG])
-						## should be PDF/JPG/PNG file, but isn't
-						error_exit "no PDF/JPG/PNG file found at ${1}" \
-							$E_NOINPUT
-						;;
-					*) ##  if page spec needed, assume this is it;
-						##  otherwise something is wrong
-						if test "$pageSpecAwaited" = true; then
-							escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g')
-							fileSpec=$(printf "%s" "$fileSpec" \
-								| sed "s/|awaited/|${escapedFilePath}/g")
-							pageSpecAwaited=false
-						else
-							error_exit "no PDF/JPG/PNG file found at ${1}" \
-								$E_NOINPUT
-						fi
-						;;
-					esac
-					;;
-				esac
-			else ## no checking of file contents; rely on .pdf extension
-				case ${1} in
-				*.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \
-					*.[jJ][pP][gG] | *.[pP][nN][gG])
-					## assume it's a PDF/JPG/PNG file
-					test -f "${1}" || error_exit \
-						"${1} not found" $E_NOINPUT
-					fileSpec="$fileSpec"$newline${1}"|"awaited
-					pageSpecAwaited=true
-					;;
-				*) ##  if page spec needed, assume this is it;
-					##  otherwise something is wrong
-					if test "$pageSpecAwaited" = true; then
-						escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g')
-						fileSpec=$(printf "%s" "$fileSpec" \
-							| sed "s/|awaited/|${escapedFilePath}/g")
-						pageSpecAwaited=false
-					else
-						error_exit "no PDF/JPG/PNG file found at ${1}" \
-							$E_NOINPUT
-					fi
-					;;
-				esac
-			fi
-			;;
+			if is_valid_pagespec "$1"; then valid_pagespec=pagespec; else valid_pagespec=; fi
+			case "$valid_input-$valid_pagespec-$pageSpecAwaited" in
+				##  12 combinations: 6 erroneous and 6 working.
+				##  Of the working combinations 1 is ambiguous and 1 dubious.
+				input-pagespec-true) prattle "Ambiguous argument '$1' interpreted as pagespec. If you meant the file, please write './$1' instead." ;;
+				input-pagespec-false) prattle "Dubious argument '$1' interpreted as file due to its position. (Write './$1' for extra clarity.)" ;;
+				path-pagespec-false) error_exit "The argument '$1' is both a valid path and a pagespec but a valid PDF/EPS/JPG/PNG file was expected." $E_NOINPUT ;;
+				path--false) error_exit "The argument '$1' is a valid path but not a valid PDF/EPS/JPG/PNG file." $E_NOINPUT ;;
+				path--true) error_exit "The argument '$1' is a valid path but not a valid PDF/EPS/JPG/PNG file or pagespec." $E_USAGE ;;
+				-pagespec-false) error_exit "The argument '$1' is a valid pagespec but not a valid PDF/EPS/JPG/PNG file." $E_NOINPUT ;;
+				--true) error_exit "Input file or pagespec expected, but '$1' neither exists in your file system nor is it a pagespec." $E_USAGE ;;
+				--false) error_exit "Input file expected, but '$1' not even exists in your file system." $E_NOINPUT ;;
+			esac
+			case "$valid_input-$valid_pagespec-$pageSpecAwaited" in  ##  The 6=3+3 working combinations
+				*-pagespec-true) fileSpec="${fileSpec%|awaited}|$1"; pageSpecAwaited=false ;;
+				input-*-*) fileSpec="$fileSpec$newline$1|$extension|awaited"; pageSpecAwaited=true ;;
+			esac
 		esac
 	fi
 	shift
@@ -789,8 +790,8 @@
 	if test -z "$fileSpec"; then
 		## no argument specifying a PDF source was given
 		inputFromStdin=true
-		fileSpec="/dev/stdin|-"
-		prattle "No PDF/JPG/PNG source specified: input is from stdin."
+		fileSpec="/dev/stdin|unknown|-"
+		prattle "No PDF/EPS/JPG/PNG source specified: input is from stdin."
 	fi
 fi
 ## Massage options
@@ -983,7 +984,7 @@
 ##
 if test "$batch" = true; then
 	if test "$fileSpec" = ""; then
-		error_exit "--batch was used, but no PDF/JPG/PNG source file(s) specified" \
+		error_exit "--batch was used, but no PDF/EPS/JPG/PNG source file(s) specified" \
 			$E_USAGE
 	fi
 	if test "$inputFromStdin" = true; then
@@ -991,14 +992,13 @@
 			$E_USAGE
 	fi
 	IFS="$newline"
-	for k in $fileSpec; do
-		sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//')
-		pageSpec=$(printf "%s" "$k" | sed 's/.*|//')
+	for k in $fileSpec; do # TODO
+		sourcePath=$(enquote "${k%|*|*}")
+		pageSpec=${k##*|}
 		callNumber=$((PDFJAM_CALL_NUMBER + 1))
 		prattle "--"
-		prattle "Processing file ${callNumber}, '$sourcePath'..."
+		prattle "Processing file ${callNumber}: $sourcePath ..."
 		prattle "Page spec is '$pageSpec'."
-		sourcePath=$(enquote "$sourcePath")
 		PDFJAM_EFFECTIVE_CALL="$0 $callOptions -- $sourcePath $pageSpec"
 		export PDFJAM_EFFECTIVE_CALL
 		PDFJAM_CALL_NUMBER=$callNumber
@@ -1029,11 +1029,8 @@
 	filePageSpec=""
 	IFS="$newline"
 	for k in $fileSpec; do
-		##  Last substitution on next line is needed for silly characters in
-		##  file names...
-		sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//')
-		sourcePath=$(enquote "$sourcePath")
-		pageSpec=$(printf "%s" "$k" | sed 's/.*|//')
+		sourcePath=$(enquote "${k%|*|*}")
+		pageSpec=${k##*|}
 		filePageSpec="$filePageSpec$sourcePath $pageSpec "
 	done
 	IFS="$OIFS"
@@ -1047,8 +1044,9 @@
 ##
 ##  NOW MAKE THE INPUT FILE ETC., READY FOR LATEX
 ##
-filePageList=""  ## initialize a string to supply to \includepdfmerge
-counter=0
+## initialize a string to supply to \includepdfmerge, forbid basename 'a'.
+filePageList=",a."
+counter=0  ## for name generation for non-harmless names
 ##
 ##  Make symbolic link(s) to the source file(s) in the temporary dir,
 ##  and make the $filePageList string for input to \includepdfmerge
@@ -1056,22 +1054,14 @@
 stdinUnread=true
 IFS="$newline"
 for k in ${fileSpec}; do
-	counter=$((counter + 1))
-	sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//')
-	pageSpec=$(printf "%s" "$k" | sed 's/.*|//')
-	##  Check, though not exhaustively, for problems with the
-	##  page spec: leading or trailing comma, double comma or
-	##  double dash, alphabetic characters other than the word "last",
-	##  braces not paired as {} with nothing inbetween.  A fully
-	##  specified pattern for valid \includepdfmerge page spec would
-	##  be better here; but life is too short...
-	if printf "%s" "$pageSpec" | sed 's/last/99/g' \
-		| grep '^,.*\|,$\|,,\|--\|[A-Za-z]\|{[^}]\|[^{]}' 1>/dev/null; then
-		error_exit "invalid page spec $pageSpec" $E_USAGE
+	sourcePath="${k%|*|*}"
+	pageSpec=${k##*|}
+	if ! is_valid_pagespec "$pageSpec"; then
+		error_exit "Bug: Somehow an invalid page spec got here: $pageSpec" $E_SOFTWARE
 	fi
-	case $sourcePath in
+	case "$sourcePath" in
 	/dev/stdin)
-		uniqueName=stdin.pdf
+		uniqueName=stdin
 		if test "$stdinUnread" = true; then
 			if tty -s; then
 				error_exit \
@@ -1079,17 +1069,32 @@
 					$E_NOINPUT
 			fi
 			cat >"$PDFJAM_TEMP_DIR/$uniqueName"
+			# Figure out the correct extension right now.
+			if extension="$(get_extension "$PDFJAM_TEMP_DIR/$uniqueName")"; then
+				mv "$PDFJAM_TEMP_DIR/$uniqueName" "$PDFJAM_TEMP_DIR/$uniqueName.$extension"
+				uniqueName="$uniqueName.$extension"
+			else
+				error_exit "Input from stdin is no legid PDF/EPS/JPG/PNG file." $E_NOINPUT
+			fi
 			stdinUnread=false
 		fi
 		;;
 	*)
-		pdfName=$(basename -- "$sourcePath")
-		sourceDir=$(dirname -- "$sourcePath") ## zsh on Mac OS 10.5 chokes here
-		cd "$sourceDir" || exit 1  ##  just to get the full path
-		sourceDir=$(pwd)
-		cd "$pwd" || exit 1
-		sourceFullPath="$sourceDir/$pdfName"
-		uniqueName="source-$counter.pdf"
+		extension="${k%|*}"
+		extension="${extension##*|}"
+		case "$extension" in
+			pdf|eps|jpg|png) ;;
+			*) error_exit "Bug: Somehow an invalid extension got here." $E_SOFTWARE
+		esac
+		sourceFullPath="$(realpath -- "$sourcePath")"
+		tmpName="$(basename -- "$sourcePath")"
+		tmpName="${tmpName%.*}"
+		if is_harmless "$tmpName" && [ -n "${filePageList##*,"$tmpName".*}" ]; then
+			uniqueName="$tmpName.$extension"
+		else
+			counter=$((counter + 1))
+			uniqueName="source-$counter.$extension"
+		fi
 		if using_non_cygwin_latex_from_cygwin; then
 			cp -f "$sourceFullPath" "$PDFJAM_TEMP_DIR/$uniqueName"
 		else
@@ -1100,7 +1105,7 @@
 	filePageList="$filePageList,$uniqueName,$pageSpec"
 done
 IFS="$OIFS"
-filePageList="${filePageList#,}"
+filePageList="${filePageList#,a.,}"
 if using_non_cygwin_latex_from_cygwin; then
 	filePageList=$(printf %s "$filePageList" | tr \\\\ /)
 fi

Modified: trunk/Master/texmf-dist/doc/man/man1/pdfjam.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/pdfjam.1	2025-02-01 20:43:20 UTC (rev 73676)
+++ trunk/Master/texmf-dist/doc/man/man1/pdfjam.1	2025-02-01 20:49:38 UTC (rev 73677)
@@ -1,50 +1,249 @@
-.TH "pdfjam" "1" "18 November 2020" "" ""
+.TH PDFJAM "1" "2025-01-30" "pdfjam 4.1" "User Commands"
 .SH "NAME"
 pdfjam \- A shell script for manipulating PDF files
 .SH "SYNOPSIS"
+.B pdfjam
+[\fI\,options\/\fR] [\fI\,--\/\fR] [\fI\,file\/\fR[\fI\,pages\/\fR]]...
+.SH "DESCRIPTION"
+pdfjam assembles a list of documents (pdf, ps, eps, jpg or png)
+into a single pdf.
+It allows to rotate, scale, reorder and combine pages freely
+using the power of the 'pdfpages' and 'graphicx' LaTeX packages.
 .PP
-pdfjam [OPTION [OPTION] \&.\&.\&.] [SRC [PAGESPEC] [SRC [PAGESPEC]] \&.\&.\&.]
+Output is written to a generated name (unless specified via \fB\-\-outfile\fR).
+The input files are embedded as graphics in the output.
+Especially jpg files are kept as is without transcoding.
+Input from stdin is supported by specifying \fI\,/dev/stdin\/\fP as a file and
+is the default if no file is given.
 .PP
-.SH "DESCRIPTION"
+By specifying \fI\,pages\/\fP it is possible to specfiy
+which pages to include in which order.
+The default '\-' selects all pages.
+An example:
+.IP
+pdfjam file1 '{},2,4\-6,9\-' ...
 .PP
-pdfjam provides a front end to most capabilities of the
-"pdfpages" package (by Andreas Matthias) of pdflatex.
-Detailed information can be found via
-"pdfjam --help", and also in the web page mentioned below\&.
+makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages
+9 onwards (up to the end of file1).
 .PP
-A working installation of pdflatex, with
-the pdfpages package, is required\&.
+A page selection can be applied to more than one file, e.g.,
+.IP
+pdfjam file1 file2 file3 last\-1 ...
 .PP
-The pdfjam script is distributed as (the main) part of the pdfjam package.
-The homepage of pdfjam is at https://github.com/pdfjam/pdfjam\&.
+applies page selection 'last\-1' (reverting the page order) to all three files;
+but for example
+.IP
+pdfjam file1 file2 2\- file3 1\-7 ...
 .PP
-.SH "SETUP"
+would apply the page selection '2\-' to file1 and file2, and '1\-7' to file3.
+A page selection applies to all the files *immediately* preceding it in the
+argument list.
 .PP
-See https://github.com/pdfjam/pdfjam
+See the pdfpages manual for more details on pagespec syntax.
+.SH "OPTIONS TO PDFPAGES AND GRAHPICX"
+Key value options to 'pdfpages' and 'graphicx' can be specified as
+\fI\,\-\-key value\,\fP.
+.SH "META OPTIONS"
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Output this text only; no processing of PDF files.
+.TP
+\fB\-\-configpath\fR
+Output the 'configpath' variable and exit immediately;
+no processing of PDF files.
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+Output the version number of pdfjam and exit immediately;
+no processing of PDF files.
+.TP
+\fB\-q\fR, \fB\-\-quiet\fR
+Suppress verbose commentary on progress.
+.SH "PROCESSING OPTIONS"
+.TP
+\fB\-\-batch\fR
+Run pdfjam sequentially on each input file in turn, and produce a separate
+output file for each input, rather than the default coalescing behaviour.
+For the location of output files, see \fB\-\-outfile\fR.
+The \fB\-\-batch\fR option cannot be used in the case of input from stdin.
+.TP
+\fB\-o\fR, \fB\-\-outfile\fR name
+Specifies where the output file(s) will go.
+If 'name' is an existing directory, pdfjam will attempt to write its output PDF
+file(s) there, with name(s) derived from the input file name(s) and the
+\fB\-\-suffix\fR option (see below).
+Otherwise the output pdf will be written at 'name'.
+.TP
+\fB\-\-suffix\fR string
+Specifies a suffix for output file names, to be used when \fB\-\-outfile\fR is
+unspecified or a directory.
+The STRING must not have zero length.
+.TP
+\fB\-\-checkfiles\fR, \fB\-\-no\-checkfiles\fR
+If the Unix 'file' utility is available, the output of 'file \fB\-Lb\fR FILE1'
+should be 'PDF document...' where '...' gives version information.
+If this is the case on your system you should use \fB\-\-checkfiles\fR;
+otherwise use \fB\-\-no\-checkfiles\fR, in which case all input files must have
+the correct extensions (.pdf, .ps, .eps .jpg, .jpeg, .png, or their uppercase
+variants).
+.TP
+\fB\-\-latex\fR pathtolatex
+Specify the LaTeX engine to be used (one of pdflatex, xelatex, lualatex).
+The pathtolatex string must be the full path to a suitable LaTeX executable (for
+example \fI\,/usr/bin/xelatex\/\fP on many unix systems).
+.TP
+\fB\-\-tidy\fR, \fB\-\-no\-tidy\fR
+Specify whether the temporary directory created by pdfjam should be deleted.
+Use '\-\-no\-tidy' or '\-\-builddir' (see below) to help debug most errors.
+.TP
+\fB\-\-builddir\fR path
+Specifies a build directory to be used in place of a temporary one.
+Existing files inside will be overwritten.
+Overrides \fB\-\-tidy\fR.
+.TP
+\fB\-\-runs\fR N
+Run latex N times, for each output document made.
+.TP
+\fB\-\-vanilla\fR
+Suppress the reading of any pdfjam configuration files.
+.TP
+\fB\-\-enc\fR
+Specify a command\-line encoding
+.SH "PAPER OPTIONS"
+.TP
+\fB\-\-paper\fR papername, \fB\-\-papername\fR
+.IP
+Specify a LaTeX paper size, for example '\-\-paper a4' or simply '\-\-a4paper'
+for ISO A4 paper.
+A wide range of paper sizes is available thanks to the LaTeX 'geometry' package.
+For details see documentation for LaTeX and/or the 'geometry' package.
+If no default value is set, obtain the system’s default paper
+via libpaper, falling back to A4.
+.TP
+\fB\-\-papersize\fR width,height
+Specify a custom paper size in points = 1/72 inch (known as bp in LaTeX and as
+pt in other software), e.g.\& \fB\-\-papersize\fR 612,792.
+Units may also be specified explicitly, e.g.\& \fB\-\-papersize\fR 10in,18cm.
+.TP
+\fB\-\-landscape\fR, \fB\-\-no\-landscape\fR
+Specify landscape page orientation (or not) in the output PDF file.
+.TP
+\fB\-\-twoside\fR, \fB\-\-no\-twoside\fR
+Specify (or not) the 'twoside' document class option.
+.TP
+\fB\-\-other\-edge\fR, \fB\-\-no\-other\-edge\fR
+Rotate every odd page by 180 degrees (or not).
+Thus changes along which edge the pages are flipped in duplex printing.
+.TP
+\fB\-\-pagecolor\fR rgbspec
+Specify a background colour for the output pages.
+The RGBSPEC must be a comma\-separated triple of integers between 0 and 255.
+An example:
+\fB\-\-pagecolor\fR 150,200,150.
+Default is no background colour.
+.SH "PDFINFO OPTIONS"
+.TP
+\fB\-\-keepinfo\fR, \fB\-\-no\-keepinfo\fR
+Preserve (or not) Title, Author, Subject and Keywords
+(from the last input PDF file, if more than one) in the output PDF file.
+This requires the pdfinfo utility, from the poppler-utils package, and the
+LaTeX 'hyperref' package; if either of those is not available, '\-\-keepinfo' is
+ignored.
+.TP
+\fB\-\-pdftitle\fR string, \fB\-\-pdfauthor\fR string,
+\fB\-\-pdfsubject\fR string, \fB\-\-pdfkeywords\fR string
+Provide text for the Title, Author, Subject and Keywords in the output PDF file.
+Requires the LaTeX 'hyperref' package.
+These options, individually, override \fB\-\-keepinfo\fR.
+.SH "ADVANCED OPTIONS"
+.TP
+\fB\-\-preamble\fR string
+Append the supplied STRING to the preamble of the LaTeX
+source file(s), immediately before the '\ebegin{document}'
+line to load LaTeX packages or set global options.
+An example:
+.IP
+pdfjam \fB\-\-nup\fR 2x2 myfile.pdf \fB\-o\fR myfile\-4up.pdf
+\fB\-\-preamble\fR '\eusepackage{fancyhdr} \epagestyle{fancy}'
 .PP
+If '\-\-preamble' is used more than once in the call,
+the supplied preamble strings are concatenated.
+For a note on avoiding clashes, see the README file,
+also available at https://github.com/pdfjam/pdfjam.
+.TP
+\fB\-\-\fR
+Signals end of options processing.
+.SH "PDFPAGES AND GRAPHICX OPTIONS"
+.TP
+\fB\-\-KEY\fR VALUE
+Specify options to '\eincludepdfmerge', in the LaTeX 'pdfpages' package.
+See the the pdfpages documentation (usually 'texdoc pdfpages') for more
+information.
+Here KEY is the name of any of the many options for '\eincludepdfmerge',
+and VALUE is a corresponding value.
+Examples:
+.IP
+\fB\-\-nup\fR 2x1
+(for 2\-up side\-by\-side imposition)
+.IP
+\fB\-\-scale\fR 0.7
+(to scale all input pages to 70% size)
+.IP
+\fB\-\-offset\fR '1cm 0.5cm'
+(to offset all pages \fB\-\-\fR note the quotes!)
+.IP
+\fB\-\-frame\fR true
+(to put a frame round each input page)
+.IP
+\fB\-\-booklet\fR true
+(to reorder the pages in signatures, generally useful with \fB\-\-nup\fR)
+.IP
+\fB\-\-signature\fR N (specify the signature size, as the number of original
+pages in a signature in the final document.
+Caveat: booklet is a short form for signature, so if you use
+\fB\-\-booklet true\fR, signature will be ignored)
+.IP
+\fB\-\-trim\fR '1cm 2cm 1cm 2cm' \fB\-\-clip\fR true
+(to trim those amounts from left, bottom, right and top, respectively, of input
+pages)
+.IP
+\fB\-\-angle\fR NNN
+(The angle of rotation in degrees.
+Angles that are not either 0, 90, 180 or 270 will still create straight
+rectangular pages, only the content will be rotated.)
 .SH "CONFIGURATION FILES"
+Defaults for the options
+\fB\-\-suffix\fR,
+\fB\-\-keepinfo\fR,
+\fB\-\-paper\fR,
+\fB\-\-outfile\fR,
+\fB\-\-landscape\fR,
+\fB\-\-twoside\fR,
+\fB\-\-tidy\fR,
+\fB\-\-latex\fR,
+\fB\-\-runs\fR,
+\fB\-\-checkfiles\fR and
+\fB\-\-preamble\fR
+can be set in site\-wide or user\-specific configuration files.
+The files searched are
+.IP
+/etc/pdfjam.conf
+/usr/share/etc/pdfjam.conf
+/usr/local/share/pdfjam.conf
+/usr/local/etc/pdfjam.conf
+$XDG_CONFIG_HOME/pdfjam.conf
+$HOME/.pdfjam.conf
 .PP
-Configuration of the PDFjam utilities involves specifying the location of
-pdflatex, the location of temporary files, specification of default page size,
-etc.  This is done in a block of lines near the top of the pdfjam script;
-settings made there are over-ridden by any that are found at a site-wide
-configuration file (at /etc/pdfjam.conf, /usr/share/etc/pdfjam.conf,
-/usr/local/share/pdfjam.conf, or /usr/local/etc/pdfjam.conf), which in turn are
-over-ridden by any that are found in a user-defaults file at ~/.pdfjam.conf\&.
+This list can be changed by editing 'configpath' in the pdfjam script.
+All of these files are ignored if the \fB\-\-vanilla\fR argument is used.
+.SH "AUTHORS"
+David Firth (2002 to 2019),
+Reuben Thomas (2020 to 2024),
+Markus Kurtz (since 2024)
+.SH "SEE ALSO"
+The LaTeX packages graphicx (https://ctan.org/pkg/graphicx)
+and pdfpages (https://ctan.org/pkg/pdfpages).
+For including eps files, see the epstopdf package
+(https://ctan.org/pkg/epstopdf).
 .PP
-.SH "LIMITATIONS AND BUGS"
-.PP
-pdfjam does not work with encrypted PDF files, and does not
-preserve hyperlinks.
-.PP
-Please report bugs! --- either at GitHub or by email, see
-https://github.com/pdfjam/pdfjam\&.
-.PP
-.SH "LICENSE"
-.PP
-pdfjam is distributed under the GNU public license.
-.PP
-.SH "AUTHOR"
-.PP
-The pdfjam package was written by David Firth and is
-maintained by Reuben Thomas and Markus Kurtz.
+For more information, including a sample configuration file, see
+https://github.com/pdfjam/pdfjam.

Modified: trunk/Master/texmf-dist/doc/man/man1/pdfjam.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/pdfjam/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/README.md	2025-02-01 20:43:20 UTC (rev 73676)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/README.md	2025-02-01 20:49:38 UTC (rev 73677)
@@ -122,7 +122,7 @@
 
 In case you want to look at the `pdfjam --help` text template online, for example
 before you decide whether to install **pdfjam**, the source is available at
-<https://github.com/pdfjam/pdfjam/blob/master/pdfjam-help.txt>.
+<https://github.com/pdfjam/pdfjam/blob/master/doc/pdfjam-help.txt>.
 
 There is also a (very basic) `man` page, accessed in the usual way
 (after installation) by
@@ -174,13 +174,12 @@
 or some other reason.
 
 The file
-[pdfjam.conf](https://github.com/pdfjam/pdfjam/raw/master/pdfjam.conf)
+[pdfjam.conf](https://github.com/pdfjam/pdfjam/raw/master/doc/pdfjam.conf)
 is a sample configuration file which can be edited as needed.  After editing,
-either install the file for site-wide use (at `/etc/pdfjam.conf`,
-`/usr/share/etc/pdfjam.conf`, `/usr/local/share/pdfjam.conf`, or
-`/usr/local/etc/pdfjam.conf`) or as a user-defaults file at `~/.pdfjam.conf`.
-User settings made at `~/.pdfjam.conf` override corresponding settings made
-in a site-wide configuration file.
+either install the file for site-wide use (e.g. at `/etc/pdfjam.conf`) or as a
+user-defaults file at `~/.pdfjam.conf` or `~/.config/pdfjam.conf`.  User
+settings override corresponding settings made in a site-wide configuration
+file.
 
 For example, if you prefer to use `/usr/bin/xelatex` as your default LaTeX engine
 (in place of the standard `pdflatex`), and you want your output page size to be
@@ -205,10 +204,10 @@
 ```
 
 On some systems it might even be necessary to change the list of places
-(i.e., `/etc/pdfjam.conf` and others as listed above) that is searched for
-site-wide configuration files.  This can only be done by editing the
-`pdfjam` script itself.  To see which directories on _your_ system are
-searched for a file named `pdfjam.conf`, look at the output of
+(i.e., `/etc/pdfjam.conf` and others) that is searched for site-wide
+configuration files.  This can only be done by editing the `pdfjam` script
+itself.  To see which directories on _your_ system are searched for a file
+named `pdfjam.conf`, look at the output of
 
 ```
 pdfjam --configpath
@@ -432,4 +431,4 @@
 who knows?  The wrapper scripts (**no longer maintained**) can now be found at
 <https://github.com/pdfjam/pdfjam-extras>.
 
-_Releases up to version 2.08 are still available at <https://davidfirth.github.io/pdfjam>._
+_Releases up to version 2.08 are still available at <https://pdfjam.github.io/pdfjam>._

Deleted: trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.00
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.00	2025-02-01 20:43:20 UTC (rev 73676)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.00	2025-02-01 20:49:38 UTC (rev 73677)
@@ -1 +0,0 @@
-This is pdfjam 4.00

Added: trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.1
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.1	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.1	2025-02-01 20:49:38 UTC (rev 73677)
@@ -0,0 +1 @@
+This is pdfjam 4.1


Property changes on: trunk/Master/texmf-dist/doc/support/pdfjam/VERSION-4.1
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/pdfjam/zsh/_pdfjam
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/zsh/_pdfjam	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/zsh/_pdfjam	2025-02-01 20:49:38 UTC (rev 73677)
@@ -0,0 +1,221 @@
+#compdef pdfjam
+
+_pdfjam() {
+	local paperformats=(a0 a1 a2 a3 a4 a5 a6 b0 b1 b2 b3 b4 b5 b6 c0 c1 c2 c3 c4 c5 c6 ansia ansib ansic ansid ansie letter legal executive b0j b1j b2j b3j b4j b5j b6j)
+	local options=(
+		# positional parameters
+		'*:file or pagespec:_files -g \*.\(pdf\|ps\|eps\|jpg\|png\)'
+		# pdfjam options
+		'(- :)'{-h,--help}'[Print help message.]'
+		'(- :)'{-V,--version}'[Print the version number.]'
+		"(- :)--configpath[Print the 'configpath' variable.]"
+		{-q,--quiet}'[Suppress verbose commentary on progress.]'
+		'--batch[Run pdfjam sequentially on each input file in turn, and produce a separate output file for each input.]'
+		{-o,--outfile}'[File or directory name for output(s).]:output:_output'
+		'--suffix[Suffix for output, when file name is not given explicitely.]:string: '
+		'(--no-checkfiles)--checkfiles[Use `file` utility to determine file type.]'
+		'(--checkfiles)--no-checkfiles[Rely on file extension to determine file type.]'
+		'*--preamble[Append code to the LaTeX preamble.]:tex code: '
+		'(--no-keepinfo)--keepinfo[Preserve Title, Author, Subject and Keywords (from the last input PDF) in the output PDF file.]'
+		'(--keepinfo)--no-keepinfo[Do not preserve Title, Author, Subject and Keywords in the output PDF file.]'
+		'--pdftitle[Set Title of the output PDF file.]:string: '
+		'--pdfauthor[Set Author of the output PDF file.]:string: '
+		'--pdfsubject[Set Subject of the output PDF file.]:string: '
+		'--pdfkeywords[Set Keywords of the output PDF file.]:string: '
+		'(--no-otheredge)--otheredge[Rotate every odd page by 180 degrees.]'
+		'(--otheredge)--no-otheredge[Do not rotate every odd page by 180 degrees.]'
+		'(--no-landscape)--landscape[Exchange width and height of paper, usually resulting in landscape.]'
+		'(--landscape)--no-landscape[Keep specified orientation of paper, usually resulting in portrait.]'
+		"(--no-twoside)--twoside[Specify 'twoside' document class option.]"
+		"(--twoside)--no-twoside[Do not specify 'twoside' document class option.]"
+		'--flip-other-edge[For signatures/booklets: flip paper for duplex printing on the other edge.]:bool:(true false)'
+		'--pagecolor[Background color.]:rgb:_pagecolor'
+		'(--builddir --tidy)--no-tidy[Preserve temporary build directory.]'
+		'(--builddir --no-tidy)--tidy[Clean temporary build directory.]'
+		'(--tidy --no-tidy)--builddir[Build directory.]:directory:_files -/'
+		'--latex[LaTeX engine to be used.]:engine:_absolute_command_paths:'
+		'--runs[Run latex N times, for each output document made.]:number of runs:_numbers -l 1 "number of runs"'
+		'--vanilla[Suppress the reading of any pdfjam configuration files.]'
+		'--enc[Command-line encoding.]:encoding:_enc'
+		# \includepdfmerge options
+		'--pages[Select pages to insert.]:pagespec: '
+		'--nup[Put multiple logical pages onto each sheet of paper.]:XxY:_nup'
+		'--landscape[Rotate output sheet format by 90 degrees.]:bool:(true false)'
+		'--delta[Put some horizontal and vertical space between the logical pages.]:Xdim Ydim:_dimens "\\ " "horizontal space,vertical space"'
+		'--offset[Displace the origin of the inserted pages.]:Xdim Ydim:_dimens "\\ " "horizontal displacement,vertical displacement"'
+		'--frame[Put a frame around each logical page.]:bool:(true false)'
+		'--column[Use column-major layout, where successive pages are arranged in columns down the paper.]:bool:(true false)'
+		'--columnstrict[For column-major layout only: Do not balance the columns on the last page.]:bool:(true false)'
+		'--openright[Put an empty page before the first logical page.]:bool:(true false)'
+		'--openrighteach[Put an empty page before the first logical page of each file.]:bool:(true false)'
+		'--pagecommand[Declare LATEX commands, which are executed on each sheet of paper.]:TEX: '
+		'--pagecommand\*[Declare LATEX commands, which are executed on the very first page only.]:TEX: '
+		'--picturecommand[Similar to pagecommand, but executed within a picture environment with base point at the lower left page corner.]:TEX: '
+		'--picturecommand\*[Similar to picturecommand, but for very first page only.]:TEX: '
+		'--turn[Tell PDF viewer to display landscape pages in lanscape orientation. On by default.]:bool:(true false)'
+		'--noautoscale[Suppress automatic scaling of pages.]:bool:(true false)'
+		'--fitpaper[Adjust the paper size to the one of the inserted document.]:bool:(true false)'
+		'--reflect[Reflect included pages.]:bool:(true false)'
+		'(--templatesize)--pagetemplate[Declare page to be used as a template. All other pages are scaled such that they match within its size.]:page number: '
+		'(--pagetemplate)--templatesize[Specify size of page template. All pages are scaled such that they match within this size.]:{Xdim}{Ydim}:_dimens , width,height'
+		'--rotateoversize[Rotate oversized pages.]:bool:(true false)'
+		'--link[Each inserted page becomes the target of the hyperlink ⟨filename⟩.⟨page number⟩.]:bool:(true false)'
+		'--linkname[For link option only: Change the linkname base from ⟨filname⟩ to name.]:name: '
+		'--thread[Combine inserted pages to an article thread.]:bool:(true false)'
+		'--threadname[For thread option only: Change the thread name from ⟨filename⟩ to name.]:name: '
+		'--linkfit[For link option only: Specify, how the viewer displays a linked page.]:destination:_linkfit'
+		'--addtotoc[Add an entry to the table of contents.]:page number, section, level, heading, label:_addtotoc'
+		'--addtolist[Add an entry to the list of figures, the list of tables, or any other list.]:page number, type, heading, label:_addtolist'
+		'--pagebox[Specify which PDF bounding box specification to read.]:bounding box:(mediabox cropbox bleedbox trimbox artbox)'
+		# \includegraphicx options
+		'--viewport[Consider image to consist of given rectangle only.]:left bottom right top:_dimens "\\ " left,bottom,right,top'
+		'--trim[Similar to viewport, but here the four lengths specify the amount to remove or add to each side.]:left bottom right top:_dimens "\\ " left,bottom,right,top'
+		'--angle[Rotation angle.]:angle:compadd -o nosort $(seq 0 15 345)'
+		'--origin[Origin for rotation.]:origin:(c l r b t bl br tl tr)'
+		'--width[Required width. The graphic is scaled to this width.]:width:_dimen width'
+		'--height[Required height. The graphic is scaled to this height.]:height:_dimen height'
+		'--totalheight[Required height+depth. Differs from height if rotation has occured.]:height:_dimen height'
+		'--keepaspectratio[Do not distort figure if both width and height are given.]:bool:(true false)'
+		'--scale[Scale factor.]:float: '
+		'--clip[Clip the graphic to the viewport.]:bool:(true false)'
+		'--draft[Switch to draft mode.]:bool:(true false)'
+		'--interpolate[Enable interpolation of bitmap images by the viewer.]:bool:(true false)'
+		# \includepdfmerge groups
+		+ '(booklet)'
+			'--signature[Create booklets by rearranging pages into signatures of 2 pages each.]:signature size:compadd -o nosort $(seq 4 4 96)'
+			'--signature\*[Similar to signature, but for right-edge binding.]:signature size:compadd -o nosort $(seq 4 4 96)'
+			'--booklet[Same as signature with signature size chosen such that all pages fit into one signature.]:bool:(true false)'
+			'--booklet\*[Similar to booklet, but for right-edge binding.]:bool:(true false)'
+		+ '(duplicatepages)'
+			'--doublepages[Insert every page twice.]:bool:(true false)'
+			'--doublepagestwist[Insert every page twice: once upside down and once normally.]:bool:(true false)'
+			'--doublepagestwistodd[Insert every page twice: once normally and once upside down.]:bool:(true false)'
+			'--doublepagestwist\*[Insert every page twice: for odd pages, the first copy is upside down; for even pages, the second copy.]:bool:(true false)'
+			'--doublepagestwistodd\*[Insert every page twice: for odd pages, the second copy is upside down; for even pages, the first copy.]:bool:(true false)'
+			'--duplicatepages[Insert every page multiple times.]:number: '
+		# pdfjam paper group
+		+ '(paper)'
+			"--paper[Paper size.]:paper name:($paperformats)"
+			"--papersize[Specify a paper size as 'WIDTH,HEIGHT'.]:width,height:_dimens , width,height"
+			--${^paperformats:#b?j}paper
+			--${(M)^paperformats:#b?j}
+	)
+	_arguments -S $options
+}
+
+_output() {
+	_alternative 'file:pdf:_files -g \*.pdf' 'directory:path:_files -/'
+}
+
+_dimen() {
+	local units=(
+		':bp:point (1/72 in)'
+		'pt:point (1/72.27 in)'
+		mm:millimeter
+		cm:centimeter
+		'in:inch (2.54 cm)'
+		'sp:scaled point (1/65536 pt)'
+		'pc:pica (12 pt)'
+		'dd:Didot point (1.07 pt)'
+		'cc:Cicero (12 dd)'
+		'ex:x-height (height of lowercase x)'
+		'em:font size (height of capital M)'
+	)
+	_numbers -f -u bp "$@" $units
+}
+
+_dimens() {
+	local sep="$argv[-2]"
+	typeset -a names=("${(s:,:)argv[-1]}")
+	typeset -i i=$#names
+	shift -p 2
+	while ((--i)); do compset -P $i "*$sep" && break; done
+	((++i))
+	[[ $i = $#names ]] || argv+=(-S "$sep")
+	_dimen "$@" "$names[$i]"
+}
+
+_nup() {
+	setopt extendedglob
+	case "$PREFIX" in
+		[0-9]##x[0-9]#) compset -P '*x'; _numbers -l 1 "$@" vertical ;;
+		[0-9]##) compset -P '*'; _numbers -l 1 "$@" horizontal; compadd "$@" -S '' x ;;
+		[0-9]#) _numbers -l 1 "$@" horizontal ;;
+		*) return 1 ;;
+	esac
+}
+
+_pagecolor() {
+	if compset -P 3 '*,'; then return 1
+	elif compset -P 2 '*,'; then
+		_numbers -l 0 -m 255 "$@" blue
+	elif compset -P 1 '*,'; then
+		_numbers -l 0 -m 255 "$@" green
+	else
+		_numbers -l 0 -m 255 "$@" red
+	fi
+}
+
+_linkfit() {
+	local expl tag
+	if compset -P 1 '*\ '; then
+		_numbers 'distance in points (1/72 in)'
+	else
+		compadd "$@" Fit FitB Region
+		compadd -S '\ ' "$@" FotV FotBH FitBV
+	fi
+}
+
+_addtotoc() { # {page number, section, level, heading, label}
+	local close expl
+	if compset -P '*\{'; then close='\}'
+	elif compset -P '*{'; then close='}'
+	fi
+	if ! compset -P 1 '*,'; then
+		compset -P '*'
+		_description -x string expl 'page number' && compadd "$expl[@]"
+		_description -x separator expl comma && compadd "$expl[@]" ,
+	elif ! compset -P 2 '*,'; then
+		_alternative 'level:level:(part,0, section,1, subsection,2, subsubsection,3,)'
+	elif ! compset -P 1 '*,'; then
+		compset -P '*'
+		_description -x string expl heading && compadd "$expl[@]"
+		_description -x separator expl comma && compadd "$expl[@]" ,
+	elif ! compset -P 1 '*,' && ! compset -P "*$close"; then
+		_description -x string expl 'LaTeX label' && compadd "$expl[@]"
+		[[ -n "$close" ]] && _description -x delimiter expl brace && compadd -Q "$expl[@]" - "$close"
+	fi
+}
+
+_addtolist() { # {page number, type, heading, label}
+	local close
+	if compset -P '*\{'; then close='\}'
+	elif compset -P '*{'; then close='}'
+	fi
+	if ! compset -P 1 '*,'; then
+		compset -P '*'
+		_description -x string expl 'page number' && compadd "$expl[@]"
+		_description -x separator expl comma && compadd "$expl[@]" ,
+	elif ! compset -P 1 '*,'; then
+		_alternative 'type:type:(figure, table,)'
+	elif ! compset -P 1 '*,'; then
+		compset -P '*'
+		_description -x string expl heading && compadd "$expl[@]"
+		_description -x separator expl comma && compadd "$expl[@]" ,
+	elif ! compset -P 1 '*,' && ! compset -P "*$close"; then
+		_description -x string expl 'LaTeX label' && compadd "$expl[@]"
+		[[ -n "$close" ]] && _description -x delimiter expl brace && compadd -Q "$expl[@]" - "$close"
+	fi
+}
+
+_enc() {
+	local enc=$(iconv -l)
+	enc=${(@q)${(ou)${${(f)enc}%//}}}
+	_alternative "encoding:code set:($enc)"
+}
+
+if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
+	_pdfjam "$@"
+else
+	compdef _pdfjam pdfjam
+fi

Modified: trunk/Master/texmf-dist/scripts/pdfjam/pdfjam
===================================================================
--- trunk/Master/texmf-dist/scripts/pdfjam/pdfjam	2025-02-01 20:43:20 UTC (rev 73676)
+++ trunk/Master/texmf-dist/scripts/pdfjam/pdfjam	2025-02-01 20:49:38 UTC (rev 73677)
@@ -1,5 +1,5 @@
 #!/bin/sh
-version=4.00
+version=4.1
 #########################################################################
 ##                                                                     ##
 ##  pdfjam: A shell-script interface to the "pdfpages" LaTeX package   ##
@@ -101,7 +101,7 @@
 	value="$1"
 	case "$value" in
 	\{*\}) ;;
-	*,* | *\]*) value="{$value}" ;;
+	*,* | *=* | *\]*) value="{$value}" ;;
 	esac
 	printf %s "$value"
 }
@@ -113,6 +113,40 @@
 	esac
 	printf %s "$value" | sed -E 's/([0-9]{1,}\.{0,1}[0-9]*)(,|$)/\1bp\2/g'
 }
+## Check whether string contains only harmless characters
+is_harmless() {
+	printf %s "$1" | grep -q '^[A-Za-z0-9.-]\+$'
+}
+##  Validate pagespec syntax
+is_valid_pagespec() {
+	# P = [0-9]*|last  is any or no page
+	# P(-P)?  is any or no page range (the latter being an implicit empty page)
+	# (P(-P)?|\{\})  is any page range or an implicit or explicit empty page
+	# (,(P(-P)?|\{\}))*  is any list of page ranges and empty pages separated by and beginning with a comma
+	printf %s ",$1" | grep -qE '^(,(([0-9]*|last)(-([0-9]*|last))?)|\{\})*$'
+}
+##  Get appropriate file extension if input is supported
+get_extension() {
+	extension=
+	if test -n "$checkfiles"; then
+		case "$(file -Lb "$(realpath -- "$1")")" in
+			'PDF document'*) extension=pdf ;;
+			'PostScript document'*) extension=eps ;;
+			'JPEG image data'*) extension=jpg ;;
+			'PNG image data'*) extension=png ;;
+		esac
+	elif test -f "$1" && test -r "$1"; then
+		case "$1" in *.*)
+			case "$(printf %s "${1##*.}" | tr A-Z a-z)" in
+				pdf) extension=pdf ;;
+				jpg|jpeg) extension=jpg ;;
+				png) extension=png ;;
+				ps|eps) extension=eps ;;
+			esac
+		esac
+	fi
+	[ -n "$extension" ] && echo "$extension"
+}
 ##
 ##  Define a function to output verbose comments:
 ##
@@ -188,8 +222,13 @@
 if [ -z "$pdfinfo" ]; then pdfinfo="not found"; fi
 iconv=$(command -v iconv)
 if [ -z "$iconv" ]; then iconv="not found"; fi
+##  Sanity check the 'file -Lb' utility to identify files if it works;
+##  rely on the file extension otherwise.
+case "$(file -Lb "$0" 2>/dev/null)" in
+	'POSIX shell script'*) checkfiles=checkfiles ;;
+	*) checkfiles=
+esac
 ##
-##
 ##  Defaults
 ##
 outFile="$pwd"      ##  Output to the current working directory
@@ -196,9 +235,6 @@
 suffix=pdfjam       ##  Default filename suffix to be used when
 ##                      --outfile is either (a) a directory, or (b)
 ##                      not specified in a --batch call.
-checkfiles=         ##  Don't use the Unix 'file -Lb' utility to
-##                      identify PDF files from their contents;
-##                      rely on the .pdf or .PDF extension instead.
 keepinfo=           ##  Don't try to preserve "pdfinfo" data
 landscape=          ##  Use portrait./Do not switch width and height.
 twoside=            ##  No "twoside" option to documentclass
@@ -310,194 +346,191 @@
 https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
 
 Usage: pdfjam [OPTIONS] [--] [FILE1 [SEL1]] [FILE2 [SEL2]]...
-where
-* 'FILE1' etc. are PDF files (JPG and PNG files are also allowed).  For
-   input from /dev/stdin, use the special name '/dev/stdin' in place of any
-   of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to
-   allow input through a pipe (note that if /dev/stdin is connected to tty,
-   an error results).  If 'FILE1' is absent, pdfjam will use '/dev/stdin'
-   (and will use '-' for the page selection -- see next item).
-* 'SEL1' is a page selection for FILE1, etc.
-   To select all pages (the default) use '-'.  See the pdfpages manual for
-   more details.  An example:
-          ... file1 '{},2,4-6,9-' ...
-   makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages
-   9 onwards (up to the end of file1).
-   A page selection can be applied to more than one file, e.g.,
-          ... file1 file2 file3 1-7 ...
-   applies page selection '1-7' to all three files; but for example
-          ... file1 file2 2- file3 1-7 ...
-   would apply the page selection '2-' to file1 and file2, and '1-7'
-   to file3.  A page selection applies to all the files *immediately*
-   preceding it in the argument list.  A missing page selection defaults to
-   '-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets
-   used by default.
-* 'options' are pdfpages specifications in the form '--KEY VALUE' (see
-   below), or
-     --help  (or -h, or -u)
-                  Output this text only; no processing of PDF files.
-     --configpath
-                  Output the 'configpath' variable and exit immediately; no
-                  processing of PDF files.
-     --version (or -V)
-                  Output the version number of pdfjam and exit immediately; no
-                  processing of PDF files.
-     --quiet  (or -q)
-                  Suppress verbose commentary on progress.
-     --batch
-                  Run pdfjam sequentially on each input file in turn, and
-                  produce a separate output file for each input, rather
-                  than the default behaviour (which is a single run of
-                  pdfjam on all of the input files, producing a single
-                  output document).  For the location of output
-                  files, see '--outfile'.  The --batch option cannot be
-                  used in the case of input from stdin.
-     --outfile PATH  (or -o PATH)
-                  Specifies where the output file(s) will go.  If PATH is an
-                  existing directory, pdfjam will attempt to write its
-                  output PDF file(s) there, with name(s) derived from the
-                  input file name(s) and the --suffix option (see below).
-                  Otherwise the output file will be PATH.  If '/dev/stdin'
-                  is the only or last input file, PATH cannot be a directory.
-                  Your current default PATH for output is:
-                  $outFile
-     --suffix STRING
-                  Specifies a suffix for output file names, to be used when
-                  --outfile is either (a) a directory, or
-                                      (b) not specified in a --batch call.
-                  A good STRING should be descriptive: for example,
-                           --suffix 'rotated'
-                  would append the text '-rotated' to the name of the input
-                  file in order to make the output file name, as in
-                  'myfile-rotated.pdf'.  The STRING must not have zero
-                  length.
-                  [Default for you at this site: suffix=$suffix]
-     --checkfiles
-     --no-checkfiles
-                  If the Unix 'file' utility is available, with options
-                  -L and -b, the output of 'file -Lb FILE1' should be
-                  'PDF document...' where '...' gives version information.
-                  If this is the case on your system you should use
-                  '--checkfiles'; otherwise use '--no-checkfiles',
-                  in which case all input PDF files must have .pdf or .PDF
-                  as their name extension.
-                  [Default for you at this site: checkfiles=$checkfiles]
-     --preamble STRING
-                  Append the supplied STRING to the preamble of the LaTeX
-                  source file(s), immediately before the '\begin{document}'
-                  line.  An example:
-                      pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\
-                          --preamble '\usepackage{fancyhdr} \pagestyle{fancy}'
-                  The '--preamble' option can be used, for example, to load
-                  LaTeX packages and/or to set global options.  If '--preamble'
-                  is used more than once in the call, the supplied preamble
-                  strings are simply concatenated.  For a note on avoiding
-                  clashes, see the README file, also available at
-                  https://github.com/pdfjam/pdfjam
-     --keepinfo
-     --no-keepinfo
-                  Preserve (or not) Title, Author, Subject and Keywords
-                  (from the last input PDF file, if more than one) in the
-                  output PDF file.  This requires the pdfinfo utility, from
-                  the xpdf package, and the LaTeX 'hyperref' package; if
-                  either of those is not available, '--keepinfo' is ignored.
-                  [Default for you at this site: keepinfo=$keepinfo]
-     --pdftitle STRING
-     --pdfauthor STRING
-     --pdfsubject STRING
-     --pdfkeywords STRING
-                  Provide text for the  Title, Author, Subject and Keywords
-                  in the output PDF file.  Requires the  LaTeX 'hyperref'
-                  package.  These options, individually, over-ride --keepinfo.
-     --otheredge
-     --no-otheredge
-                  Rotate every odd page by 180 degrees (or not).  Thus changes
-                  along which edge the pages are flipped in duplex printing.
-     --landscape
-     --no-landscape
-                  Specify landscape page orientation (or not) in the
-                  output PDF file.
-                  [Default for you at this site: landscape=$landscape]
-     --twoside
-     --no-twoside
-                  Specify (or not) the 'twoside' document class option.
-                  [Default for you at this site: twoside=$twoside]
-     --paper PAPERSPEC  (or simply --PAPERSPEC)
-                  Specify a LaTeX paper size, for example
-                  '--paper a4' or simply '--a4paper' for ISO A4 paper.
-                  A wide range of paper sizes is available thanks to the
-                  LaTeX 'geometry' package.  For details see documentation
-                  for LaTeX and/or the 'geometry' package.
-                  If no default value is set and libpaper is not available,
-                  A4 is used.
-                  [Default for you at this site: paper=$paper]
-     --papersize 'WIDTH,HEIGHT'
-                  Specify a custom paper size in points = 1/72 inch (known as
-                  bp in LaTeX and as pt in other software), e.g.
-                      --papersize 612,792
-                  Units may also be specified explicitly, e.g.
-                      --papersize 10in,18cm
-                  [Default for you at this site: papersize=$papersize]
-     --pagecolor RGBSPEC
-                  Specify a background colour for the output pages.  The
-                  RGBSPEC must be a comma-separated trio of integers
-                  between 0 and 255.  An example:
-                         --pagecolor 150,200,150
-                  [Default is no background colour]
-     --tidy
-     --no-tidy
-                  Specify whether the temporary directory created by
-                  pdfjam should be deleted.  Use '--no-tidy' or '--builddir'
-                  below to help debug most errors.
-                  [Default for you at this site: tidy=$tidy]
-     --builddir PATH
-                  Specifies a build directory to be used in place of a
-                  temporary one. Existing files inside will be overwritten.
-     --latex PATHTOLATEX
-                  Specify the LaTeX engine to be used (one of pdflatex,
-                  xelatex, lualatex).  The PATHTOLATEX string must be
-                  the full path to a suitable LaTeX executable (for example
-                  /usr/bin/xelatex on many unix systems).
-                  [Default for you at this site: latex=$latex]
-     --runs N
-                  Run latex N times, for each output document made.
-                  [Default for you at this site: runs=$runs]
-     --vanilla
-                  Suppress the reading of any pdfjam configuration files.
-     --enc
-                  Specify a command-line encoding
-                  [Default for you at this site: enc=$enc]
-     --KEY VALUE
-                  Specify options to '\includepdfmerge', in the LaTeX
-                  'pdfpages' package.  See the the pdfpages documentation
-                  (usually 'texdoc pdfpages') for more information.
-                  Here KEY is the name of any of the many options for
-                  '\includepdfmerge', and VALUE is a corresponding value.
-                  Examples:
-                      --nup 2x1     (for 2-up side-by-side imposition)
-                      --scale 0.7   (to scale all input pages to 70% size)
-                      --offset '1cm 0.5cm'
-                                    (to offset all pages -- note the quotes!)
-                      --frame true  (to put a frame round each input page)
-                      --booklet true (to reorder the pages in signatures,
-                                      generally useful with --nup)
-                      --signature N (specify the signature size, as the
-                                     number of original pages in a signature
-                                     in the final document. Caveat: booklet
-                                     is a short form for signature, so if
-                                     you use booklet true, signature will be
-                                     ignored)
-                      --trim '1cm 2cm 1cm 2cm' --clip true
-                                    (to trim those amounts from left, bottom,
-                                     right and top, respectively, of input
-                                     pages)
-                      --angle NNN (The angle of rotation in degrees. Angles
-                                   that are not either 90, 180 or 270 will
-                                   still create straight rectangular pages,
-                                   only the content will be rotated.)
-                  etc., etc.  For more information see the manual for
-                  the 'pdfpages' package, at
-                  https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
+
+'FILE1' etc. are PDF files (JPG and PNG files are also allowed).  For
+input from /dev/stdin, use the special name '/dev/stdin' in place of any
+of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to
+allow input through a pipe (note that if /dev/stdin is connected to tty,
+an error results).  If 'FILE1' is absent, pdfjam will use '/dev/stdin'
+(and will use '-' for the page selection -- see next item).
+
+'SEL1' is a page selection for FILE1, etc.
+To select all pages (the default) use '-'.  See the pdfpages manual for
+more details.  An example:
+       ... file1 '{},2,4-6,9-' ...
+makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages
+9 onwards (up to the end of file1).
+A page selection can be applied to more than one file, e.g.,
+       ... file1 file2 file3 1-7 ...
+applies page selection '1-7' to all three files; but for example
+       ... file1 file2 2- file3 1-7 ...
+would apply the page selection '2-' to file1 and file2, and '1-7'
+to file3.  A page selection applies to all the files *immediately*
+preceding it in the argument list.  A missing page selection defaults to
+'-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets
+used by default.
+
+'options' are pdfpages specifications in the form '--KEY VALUE' (see
+below), or
+
+  -h, --help
+               Output this text only; no processing of PDF files.
+  --configpath
+               Output the 'configpath' variable and exit immediately; no
+               processing of PDF files.
+  -V, --version
+               Output the version number of pdfjam and exit immediately; no
+               processing of PDF files.
+  -q, --quiet
+               Suppress verbose commentary on progress.
+  --batch
+               Run pdfjam sequentially on each input file in turn, and
+               produce a separate output file for each input, rather
+               than the default behaviour (which is a single run of
+               pdfjam on all of the input files, producing a single
+               output document).  For the location of output
+               files, see '--outfile'.  The --batch option cannot be
+               used in the case of input from stdin.
+  -o, --outfile PATH
+               Specifies where the output file(s) will go.  If PATH is an
+               existing directory, pdfjam will attempt to write its
+               output PDF file(s) there, with name(s) derived from the
+               input file name(s) and the --suffix option (see below).
+               Otherwise the output file will be PATH.  If '/dev/stdin'
+               is the only or last input file, PATH cannot be a directory.
+               Your current default PATH for output is:
+               $outFile
+  --suffix STRING
+               Specifies a suffix for output file names, to be used when
+               --outfile is either (a) a directory, or
+                                   (b) not specified in a --batch call.
+               A good STRING should be descriptive: for example,
+                        --suffix 'rotated'
+               would append the text '-rotated' to the name of the input
+               file in order to make the output file name, as in
+               'myfile-rotated.pdf'.  The STRING must not have zero
+               length.
+               [Default for you at this site: suffix=$suffix]
+  --checkfiles, --no-checkfiles
+               If the Unix 'file' utility is available, with options
+               -L and -b, the output of 'file -Lb FILE1' should be
+               'PDF document...' where '...' gives version information.
+               If this is the case on your system you should use
+               '--checkfiles'; otherwise use '--no-checkfiles',
+               in which case all input PDF files must have .pdf or .PDF
+               as their name extension.
+               [Default for you at this site: checkfiles=$checkfiles]
+  --preamble STRING
+               Append the supplied STRING to the preamble of the LaTeX
+               source file(s), immediately before the '\begin{document}'
+               line.  An example:
+                   pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\
+                       --preamble '\usepackage{fancyhdr} \pagestyle{fancy}'
+               The '--preamble' option can be used, for example, to load
+               LaTeX packages and/or to set global options.  If '--preamble'
+               is used more than once in the call, the supplied preamble
+               strings are simply concatenated.  For a note on avoiding
+               clashes, see the README file, also available at
+               https://github.com/pdfjam/pdfjam
+  --keepinfo, --no-keepinfo
+               Preserve (or not) Title, Author, Subject and Keywords
+               (from the last input PDF file, if more than one) in the
+               output PDF file.  This requires the pdfinfo utility, from
+               the xpdf package, and the LaTeX 'hyperref' package; if
+               either of those is not available, '--keepinfo' is ignored.
+               [Default for you at this site: keepinfo=$keepinfo]
+  --pdftitle STRING
+  --pdfauthor STRING
+  --pdfsubject STRING
+  --pdfkeywords STRING
+               Provide text for the  Title, Author, Subject and Keywords
+               in the output PDF file.  Requires the  LaTeX 'hyperref'
+               package.  These options, individually, over-ride --keepinfo.
+  --otheredge, --no-otheredge
+               Rotate every odd page by 180 degrees (or not).  Thus changes
+               along which edge the pages are flipped in duplex printing.
+  --landscape, --no-landscape
+               Specify landscape page orientation (or not) in the
+               output PDF file.
+               [Default for you at this site: landscape=$landscape]
+  --twoside, --no-twoside
+               Specify (or not) the 'twoside' document class option.
+               [Default for you at this site: twoside=$twoside]
+  --paper PAPERSPEC  (or simply --PAPERSPEC)
+               Specify a LaTeX paper size, for example
+               '--paper a4' or simply '--a4paper' for ISO A4 paper.
+               A wide range of paper sizes is available thanks to the
+               LaTeX 'geometry' package.  For details see documentation
+               for LaTeX and/or the 'geometry' package.
+               If no default value is set and libpaper is not available,
+               A4 is used.
+               [Default for you at this site: paper=$paper]
+  --papersize WIDTH,HEIGHT
+               Specify a custom paper size in points = 1/72 inch (known as
+               bp in LaTeX and as pt in other software), e.g.
+                   --papersize 612,792
+               Units may also be specified explicitly, e.g.
+                   --papersize 10in,18cm
+               [Default for you at this site: papersize=$papersize]
+  --pagecolor RGBSPEC
+               Specify a background colour for the output pages.  The
+               RGBSPEC must be a comma-separated trio of integers
+               between 0 and 255.  An example:
+                      --pagecolor 150,200,150
+               [Default is no background colour]
+  --tidy, --no-tidy
+               Specify whether the temporary directory created by
+               pdfjam should be deleted.  Use '--no-tidy' or '--builddir'
+               below to help debug most errors.
+               [Default for you at this site: tidy=$tidy]
+  --builddir PATH
+               Specifies a build directory to be used in place of a
+               temporary one. Existing files inside will be overwritten.
+  --latex PATHTOLATEX
+               Specify the LaTeX engine to be used (one of pdflatex,
+               xelatex, lualatex).  The PATHTOLATEX string must be
+               the full path to a suitable LaTeX executable (for example
+               /usr/bin/xelatex on many unix systems).
+               [Default for you at this site: latex=$latex]
+  --runs N
+               Run latex N times, for each output document made.
+               [Default for you at this site: runs=$runs]
+  --vanilla
+               Suppress the reading of any pdfjam configuration files.
+  --enc
+               Specify a command-line encoding
+               [Default for you at this site: enc=$enc]
+  --KEY VALUE
+               Specify options to '\includepdfmerge', in the LaTeX
+               'pdfpages' package.  See the the pdfpages documentation
+               (usually 'texdoc pdfpages') for more information.
+               Here KEY is the name of any of the many options for
+               '\includepdfmerge', and VALUE is a corresponding value.
+               Examples:
+                   --nup 2x1     (for 2-up side-by-side imposition)
+                   --scale 0.7   (to scale all input pages to 70% size)
+                   --offset '1cm 0.5cm'
+                                 (to offset all pages -- note the quotes!)
+                   --frame true  (to put a frame round each input page)
+                   --booklet true (to reorder the pages in signatures,
+                                   generally useful with --nup)
+                   --signature N (specify the signature size, as the
+                                  number of original pages in a signature
+                                  in the final document. Caveat: booklet
+                                  is a short form for signature, so if
+                                  you use booklet true, signature will be
+                                  ignored)
+                   --trim '1cm 2cm 1cm 2cm' --clip true
+                                 (to trim those amounts from left, bottom,
+                                  right and top, respectively, of input
+                                  pages)
+                   --angle NNN (The angle of rotation in degrees. Angles
+                                that are not either 90, 180 or 270 will
+                                still create straight rectangular pages,
+                                only the content will be rotated.)
+               etc., etc.  For more information see the manual for
+               the 'pdfpages' package, at
+               https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
 * '--' can be used to signal that there are no more options to come.
 
 Defaults for the options '--suffix', '--keepinfo', '--paper', '--outfile',
@@ -575,13 +608,13 @@
 ##  First note any '--checkfiles' or '--no-checkfiles' option
 ##
 for arg; do
-	case $arg in
+	case "$arg" in
 	--checkfiles)
 		checkfiles=checkfiles
-		callOptions="$callOptions $1";;
+		callOptions="$callOptions $arg";;
 	--no-checkfiles)
 		checkfiles=
-		callOptions="$callOptions $1";;
+		callOptions="$callOptions $arg";;
 	esac
 done
 while test -n "$1$2"; do
@@ -689,6 +722,15 @@
 				otheredge=
 				callOptions="$callOptions --no-otheredge"
 				;;
+			--templatesize)  ##  provide more friendly syntax
+				case "$2" in
+					\{*\}) value="$2" ;;
+					*) value="{${2%%,*}}{${2#*,}}" ;;
+				esac
+				miscOptions="$miscOptions,${1#--}=$value"
+				callOptions="$callOptions ${1} $(enquote "$2")"
+				shift
+				;;
 			--*) ##  miscellaneous options for \includepdfmerge
 				miscOptions="$miscOptions,${1#--}=$(embrace "$2")"
 				callOptions="$callOptions ${1} $(enquote "$2")"
@@ -704,76 +746,35 @@
 	if test "$optionsFinished" = true || test "$argUnmatched" = true; then
 		case "$1" in
 		"" | /dev/stdin)
-			fileSpec="$fileSpec$newline/dev/stdin|awaited"
+			fileSpec="$fileSpec$newline/dev/stdin|unknown|awaited"
 			pageSpecAwaited=true
 			inputFromStdin=true
 			;;
-		-)
-			if test "$pageSpecAwaited" = true; then
-				fileSpec=$(printf %s "$fileSpec" | sed 's/|awaited/|-/g')
-				pageSpecAwaited=false
+		*) ##  All other args should be source files or page selections; if not, we'll quit
+			if ! [ -e "$1" ]; then
+				valid_input=
+			elif extension="$(get_extension "$1")"; then
+				valid_input=input
 			else
-				error_exit "no PDF/JPG/PNG file found at ${1}" \
-					$E_NOINPUT
+				valid_input=path
 			fi
-			;;
-		*) ##  All other args should be PDF (or JPG/PNG)
-			##  source files and page selections; if not, we'll quit
-			if test -n "$checkfiles"; then ## not always available
-				case $(file -Lb -- "$1") in
-				"PDF document"* | "JPEG image data"* | "PNG image"*)
-					##  it's a PDF file (or JPG/PNG) as expected
-					fileSpec="$fileSpec$newline$1|awaited"
-					pageSpecAwaited=true
-					;;
-				*)
-					case ${1} in
-					*.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \
-						*.[jJ][pP][gG] | *.[pP][nN][gG])
-						## should be PDF/JPG/PNG file, but isn't
-						error_exit "no PDF/JPG/PNG file found at ${1}" \
-							$E_NOINPUT
-						;;
-					*) ##  if page spec needed, assume this is it;
-						##  otherwise something is wrong
-						if test "$pageSpecAwaited" = true; then
-							escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g')
-							fileSpec=$(printf "%s" "$fileSpec" \
-								| sed "s/|awaited/|${escapedFilePath}/g")
-							pageSpecAwaited=false
-						else
-							error_exit "no PDF/JPG/PNG file found at ${1}" \
-								$E_NOINPUT
-						fi
-						;;
-					esac
-					;;
-				esac
-			else ## no checking of file contents; rely on .pdf extension
-				case ${1} in
-				*.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \
-					*.[jJ][pP][gG] | *.[pP][nN][gG])
-					## assume it's a PDF/JPG/PNG file
-					test -f "${1}" || error_exit \
-						"${1} not found" $E_NOINPUT
-					fileSpec="$fileSpec"$newline${1}"|"awaited
-					pageSpecAwaited=true
-					;;
-				*) ##  if page spec needed, assume this is it;
-					##  otherwise something is wrong
-					if test "$pageSpecAwaited" = true; then
-						escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g')
-						fileSpec=$(printf "%s" "$fileSpec" \
-							| sed "s/|awaited/|${escapedFilePath}/g")
-						pageSpecAwaited=false
-					else
-						error_exit "no PDF/JPG/PNG file found at ${1}" \
-							$E_NOINPUT
-					fi
-					;;
-				esac
-			fi
-			;;
+			if is_valid_pagespec "$1"; then valid_pagespec=pagespec; else valid_pagespec=; fi
+			case "$valid_input-$valid_pagespec-$pageSpecAwaited" in
+				##  12 combinations: 6 erroneous and 6 working.
+				##  Of the working combinations 1 is ambiguous and 1 dubious.
+				input-pagespec-true) prattle "Ambiguous argument '$1' interpreted as pagespec. If you meant the file, please write './$1' instead." ;;
+				input-pagespec-false) prattle "Dubious argument '$1' interpreted as file due to its position. (Write './$1' for extra clarity.)" ;;
+				path-pagespec-false) error_exit "The argument '$1' is both a valid path and a pagespec but a valid PDF/EPS/JPG/PNG file was expected." $E_NOINPUT ;;
+				path--false) error_exit "The argument '$1' is a valid path but not a valid PDF/EPS/JPG/PNG file." $E_NOINPUT ;;
+				path--true) error_exit "The argument '$1' is a valid path but not a valid PDF/EPS/JPG/PNG file or pagespec." $E_USAGE ;;
+				-pagespec-false) error_exit "The argument '$1' is a valid pagespec but not a valid PDF/EPS/JPG/PNG file." $E_NOINPUT ;;
+				--true) error_exit "Input file or pagespec expected, but '$1' neither exists in your file system nor is it a pagespec." $E_USAGE ;;
+				--false) error_exit "Input file expected, but '$1' not even exists in your file system." $E_NOINPUT ;;
+			esac
+			case "$valid_input-$valid_pagespec-$pageSpecAwaited" in  ##  The 6=3+3 working combinations
+				*-pagespec-true) fileSpec="${fileSpec%|awaited}|$1"; pageSpecAwaited=false ;;
+				input-*-*) fileSpec="$fileSpec$newline$1|$extension|awaited"; pageSpecAwaited=true ;;
+			esac
 		esac
 	fi
 	shift
@@ -789,8 +790,8 @@
 	if test -z "$fileSpec"; then
 		## no argument specifying a PDF source was given
 		inputFromStdin=true
-		fileSpec="/dev/stdin|-"
-		prattle "No PDF/JPG/PNG source specified: input is from stdin."
+		fileSpec="/dev/stdin|unknown|-"
+		prattle "No PDF/EPS/JPG/PNG source specified: input is from stdin."
 	fi
 fi
 ## Massage options
@@ -983,7 +984,7 @@
 ##
 if test "$batch" = true; then
 	if test "$fileSpec" = ""; then
-		error_exit "--batch was used, but no PDF/JPG/PNG source file(s) specified" \
+		error_exit "--batch was used, but no PDF/EPS/JPG/PNG source file(s) specified" \
 			$E_USAGE
 	fi
 	if test "$inputFromStdin" = true; then
@@ -991,14 +992,13 @@
 			$E_USAGE
 	fi
 	IFS="$newline"
-	for k in $fileSpec; do
-		sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//')
-		pageSpec=$(printf "%s" "$k" | sed 's/.*|//')
+	for k in $fileSpec; do # TODO
+		sourcePath=$(enquote "${k%|*|*}")
+		pageSpec=${k##*|}
 		callNumber=$((PDFJAM_CALL_NUMBER + 1))
 		prattle "--"
-		prattle "Processing file ${callNumber}, '$sourcePath'..."
+		prattle "Processing file ${callNumber}: $sourcePath ..."
 		prattle "Page spec is '$pageSpec'."
-		sourcePath=$(enquote "$sourcePath")
 		PDFJAM_EFFECTIVE_CALL="$0 $callOptions -- $sourcePath $pageSpec"
 		export PDFJAM_EFFECTIVE_CALL
 		PDFJAM_CALL_NUMBER=$callNumber
@@ -1029,11 +1029,8 @@
 	filePageSpec=""
 	IFS="$newline"
 	for k in $fileSpec; do
-		##  Last substitution on next line is needed for silly characters in
-		##  file names...
-		sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//')
-		sourcePath=$(enquote "$sourcePath")
-		pageSpec=$(printf "%s" "$k" | sed 's/.*|//')
+		sourcePath=$(enquote "${k%|*|*}")
+		pageSpec=${k##*|}
 		filePageSpec="$filePageSpec$sourcePath $pageSpec "
 	done
 	IFS="$OIFS"
@@ -1047,8 +1044,9 @@
 ##
 ##  NOW MAKE THE INPUT FILE ETC., READY FOR LATEX
 ##
-filePageList=""  ## initialize a string to supply to \includepdfmerge
-counter=0
+## initialize a string to supply to \includepdfmerge, forbid basename 'a'.
+filePageList=",a."
+counter=0  ## for name generation for non-harmless names
 ##
 ##  Make symbolic link(s) to the source file(s) in the temporary dir,
 ##  and make the $filePageList string for input to \includepdfmerge
@@ -1056,22 +1054,14 @@
 stdinUnread=true
 IFS="$newline"
 for k in ${fileSpec}; do
-	counter=$((counter + 1))
-	sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//')
-	pageSpec=$(printf "%s" "$k" | sed 's/.*|//')
-	##  Check, though not exhaustively, for problems with the
-	##  page spec: leading or trailing comma, double comma or
-	##  double dash, alphabetic characters other than the word "last",
-	##  braces not paired as {} with nothing inbetween.  A fully
-	##  specified pattern for valid \includepdfmerge page spec would
-	##  be better here; but life is too short...
-	if printf "%s" "$pageSpec" | sed 's/last/99/g' \
-		| grep '^,.*\|,$\|,,\|--\|[A-Za-z]\|{[^}]\|[^{]}' 1>/dev/null; then
-		error_exit "invalid page spec $pageSpec" $E_USAGE
+	sourcePath="${k%|*|*}"
+	pageSpec=${k##*|}
+	if ! is_valid_pagespec "$pageSpec"; then
+		error_exit "Bug: Somehow an invalid page spec got here: $pageSpec" $E_SOFTWARE
 	fi
-	case $sourcePath in
+	case "$sourcePath" in
 	/dev/stdin)
-		uniqueName=stdin.pdf
+		uniqueName=stdin
 		if test "$stdinUnread" = true; then
 			if tty -s; then
 				error_exit \
@@ -1079,17 +1069,32 @@
 					$E_NOINPUT
 			fi
 			cat >"$PDFJAM_TEMP_DIR/$uniqueName"
+			# Figure out the correct extension right now.
+			if extension="$(get_extension "$PDFJAM_TEMP_DIR/$uniqueName")"; then
+				mv "$PDFJAM_TEMP_DIR/$uniqueName" "$PDFJAM_TEMP_DIR/$uniqueName.$extension"
+				uniqueName="$uniqueName.$extension"
+			else
+				error_exit "Input from stdin is no legid PDF/EPS/JPG/PNG file." $E_NOINPUT
+			fi
 			stdinUnread=false
 		fi
 		;;
 	*)
-		pdfName=$(basename -- "$sourcePath")
-		sourceDir=$(dirname -- "$sourcePath") ## zsh on Mac OS 10.5 chokes here
-		cd "$sourceDir" || exit 1  ##  just to get the full path
-		sourceDir=$(pwd)
-		cd "$pwd" || exit 1
-		sourceFullPath="$sourceDir/$pdfName"
-		uniqueName="source-$counter.pdf"
+		extension="${k%|*}"
+		extension="${extension##*|}"
+		case "$extension" in
+			pdf|eps|jpg|png) ;;
+			*) error_exit "Bug: Somehow an invalid extension got here." $E_SOFTWARE
+		esac
+		sourceFullPath="$(realpath -- "$sourcePath")"
+		tmpName="$(basename -- "$sourcePath")"
+		tmpName="${tmpName%.*}"
+		if is_harmless "$tmpName" && [ -n "${filePageList##*,"$tmpName".*}" ]; then
+			uniqueName="$tmpName.$extension"
+		else
+			counter=$((counter + 1))
+			uniqueName="source-$counter.$extension"
+		fi
 		if using_non_cygwin_latex_from_cygwin; then
 			cp -f "$sourceFullPath" "$PDFJAM_TEMP_DIR/$uniqueName"
 		else
@@ -1100,7 +1105,7 @@
 	filePageList="$filePageList,$uniqueName,$pageSpec"
 done
 IFS="$OIFS"
-filePageList="${filePageList#,}"
+filePageList="${filePageList#,a.,}"
 if using_non_cygwin_latex_from_cygwin; then
 	filePageList=$(printf %s "$filePageList" | tr \\\\ /)
 fi

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2025-02-01 20:43:20 UTC (rev 73676)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2025-02-01 20:49:38 UTC (rev 73677)
@@ -1112,7 +1112,6 @@
  'pdf-forms-tutorial-de', "die 'skipping, requires acrobat'", #"&MAKEpdf_forms_tutorial",
  'pdf-forms-tutorial-en', "die 'skipping, requires acrobat'", #"&MAKEpdf_forms_tutorial",
  'pdfbook',     "die 'skipping, requires compilation'",
- 'pdfjam',      "&MAKEflatten",
  'pdfmarginpar',"&MAKEflatten",
  'pdfrack',     "die 'skipping, until someone asks for it'",
  'pdftex-def',	"die 'skipping, replaced by graphics-def'",
@@ -1676,6 +1675,7 @@
  'optex'		=> '&PREHOOK_optex',
  'optexcount'		=> '&PREHOOK_optexcount',
  'pgfornament'		=> '&PREHOOK_flatten1',
+ 'pdfjam'		=> '&PREHOOK_flatten1',
  'phonetic'		=> '&PREHOOK_flatten1',
  'pictex'               => '&PREHOOK_pictex',
  'pkuthss'              => '&PREHOOK_flatten1',
@@ -3914,7 +3914,7 @@
  'pax'			=> 'pdfannotextractor.pl$',
  'pdfbook2'             => 'pdfbook2$',
  'pdfcrop'              => '\.pl$',             # doscripts() does r*
- 'pdfjam'               => 'pdfjam$',
+ 'pdfjam'               => '^pdfjam$',
  'pdflatexpicscale'	=> '\.pl$',	
  'pdftex-quiet'		=> 'pdftex-quiet$',
  'pdfxup'               => 'pdfxup$',
@@ -4034,7 +4034,7 @@
  'pedigree-perl'        => '\.1$',
  'perltex'              => 'perltex.1',
  'pdfbook2'             => '\.1$',
- 'pdfjam'               => '\.1$',
+ 'pdfjam'               => 'pdfjam\.1$',
  'pdfxup'               => '\.1$',
  'pmx'                  => '\.1$',
  'ppmcheckpdf'          => '\.1$',



More information about the tex-live-commits mailing list.