Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fithesis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
External Relations
Document Templates
fithesis
Commits
abfc0479
There was an error fetching the commit references. Please try again later.
Commit
abfc0479
authored
8 years ago
by
Vít Novotný
Browse files
Options
Downloads
Patches
Plain Diff
The `comparepdf.sh` script no longer relies on bash.
parent
2c578ecb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/mu/comparepdf.sh
+11
-9
11 additions, 9 deletions
test/mu/comparepdf.sh
with
11 additions
and
9 deletions
test/mu/comparepdf.sh
+
11
−
9
View file @
abfc0479
#!/bin/
ba
sh
#!/bin/sh
# This script visually compares two PDF documents on a page-by-page basis.
# Print an error message and die.
die
()
{
printf
"
$1
\n
"
"
${
@
:2
}
"
1>&2
FORMAT
=
"
$1
"
;
shift
printf
"
$FORMAT
\n
"
"
$@
"
1>&2
exit
1
}
# Check if a file exist.
exists
()
{
[
[
-e
"
$1
"
]
]
||
die
'File "%s" does not exist.'
"
$1
"
[
-e
"
$1
"
]
||
die
'File "%s" does not exist.'
"
$1
"
}
# Check that the input files exist.
...
...
@@ -24,20 +25,21 @@ DEST_DIR=`mktemp -d` && trap 'rm -r $SOURCE_DIR $DEST_DIR' EXIT &&
# Compare the individual pages.
DIFFER
=
false
;
PAGES
=
""
while
read
PAGE
;
do
if
[
[
-e
$SOURCE_DIR
/
$PAGE
&&
!
-e
$DEST_DIR
/
$PAGE
]
]
;
then
for
PAGE
in
`
((
cd
$SOURCE_DIR
&&
ls
*
.pdf
)
&&
(
cd
$DEST_DIR
&&
ls
*
.pdf
))
|
sort
-u
`
;
do
if
[
-e
$SOURCE_DIR
/
$PAGE
-a
!
-e
$DEST_DIR
/
$PAGE
]
;
then
die
'The document "%s" does not contain page "%d".'
"
$1
"
"
${
PAGE
%%.pdf
}
"
elif
[
[
!
-e
$SOURCE_DIR
/
$PAGE
&&
-e
$DEST_DIR
/
$PAGE
]
]
;
then
elif
[
!
-e
$SOURCE_DIR
/
$PAGE
-a
-e
$DEST_DIR
/
$PAGE
]
;
then
die
'The document "%s" does not contain page "%d".'
"
$2
"
"
${
PAGE
%%.pdf
}
"
else
if
!
comparepdf
--compare
=
appearance
--verbose
=
0
$SOURCE_DIR
/
$PAGE
$DEST_DIR
/
$PAGE
;
then
DIFFER
=
true
PAGES
=
"
$PAGES
${
PAGE
%%.pdf
}
"
PAGES
=
"
$PAGES
,
`
echo
${
PAGE
%%.pdf
}
|
sed
's/^0*//'
`
"
fi
fi
done
< <
(((
cd
$SOURCE_DIR
&&
ls
*
.pdf
)
&&
(
cd
$DEST_DIR
&&
ls
*
.pdf
))
|
sort
-u
)
done
# Print out the result.
if
$DIFFER
;
then
die
'The documents "%s" and "%s" differ in pages%s.'
"
$1
"
"
$2
"
"
$PAGES
"
PAGES
=
"
$(
echo
"
$PAGES
"
|
tail
-c
+3
)
"
die
'The documents "%s" and "%s" differ in pages %s.'
"
$1
"
"
$2
"
"
$PAGES
"
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment