Commit 5f9aaa3c authored by User expired's avatar User expired
Browse files

newbib: Per default make a backup of the bibtex file

parent d2c0aa4e
Pipeline #69989 failed with stage
in 45 seconds
......@@ -9,6 +9,7 @@ USAGE: $(basename $0) [target_dir] bibfiles
'target_dir' must be an existing directory.
Options:
-h print this help
-b do not make backup files with suffix '.bak'
-n show changes only (basic formatting is applied)
-f full instead of abbreviated journal names
-u do not change field contents
......@@ -21,6 +22,7 @@ if [ $# -lt 1 ]; then usage 1; fi
targetdir=.
# Default options.
BACKUP=1 # Make a backup copy with suffix '.bak'.
DRYRUN="" # No dry run option for bib-* tools.
ACTION="eval" # Execute commands (no dry run).
FULLNAME="" # Use long journal names.
......@@ -31,6 +33,8 @@ SKIPJABBR="" # Journal may not be abbreviated.
for arg; do
# With option '-h' print usage and exit.
if [[ "$arg" == "-h" ]]; then usage 0; fi
# With option '-b' do not make a backup file.
if [[ "$arg" == "-b" ]]; then BACKUP=0; fi
# With option '-n' only print changes/actions.
if [[ "$arg" == "-n" ]]; then
DRYRUN="-n"
......@@ -53,6 +57,7 @@ fi
for bibfile in "$@"
do
# Skip options.
test "$bibfile" != "-b" || continue
test "$bibfile" != "-n" || continue
test "$bibfile" != "-f" || continue
test "$bibfile" != "-u" || continue
......@@ -71,6 +76,12 @@ do
continue
}
# Create a backup copy with suffix '.bak'.
if [ $BACKUP -eq 1 ]
then
cp -a "${bibfile}" "${bibfile}.bak"
fi
# Apply basic formatting for dry run.
if [ -n "$DRYRUN" ]
then
......
......@@ -10,6 +10,7 @@ If unspecified, files that are unique by suffix are chosen.
The 'target_dir' must be an existing directory.
Options:
-h print this help
-b do not make backup files with suffix '.bak'
-n show changes only (basic formatting is applied)
-f full instead of abbreviated journal names
-u do not change field contents
......@@ -24,6 +25,7 @@ EOF
TARGETDIR=new_lit
# Default options.
BACKUP=1 # Make a backup copy with suffix '.bak'.
DRYRUN="" # No dry run option for bib-* tools.
ACTION="eval" # Execute commands (no dry run).
FULLNAME="" # Use long journal names.
......@@ -35,6 +37,8 @@ SKIPJABBR="" # Journal may not be abbreviated.
for arg; do
# With option '-h' print usage and exit.
if [[ "$arg" == "-h" ]]; then usage 0; fi
# With option '-b' do not make a backup file.
if [[ "$arg" == "-b" ]]; then BACKUP=0; fi
# With option '-n' only print changes/actions.
if [[ "$arg" == "-n" ]]; then
DRYRUN="-n"
......@@ -59,6 +63,7 @@ fi
for arg
do
# Skip options.
test "$arg" != "-b" || continue
test "$arg" != "-n" || continue
test "$arg" != "-f" || continue
test "$arg" != "-u" || continue
......@@ -179,6 +184,12 @@ then
exit 1
fi >/dev/stderr
# Create a backup copy with suffix '.bak'.
if [ $BACKUP -eq 1 ]
then
cp -a "${BIBFILE}" "${BIBFILE}.bak"
fi
# Apply basic formatting for dry run.
if [ -n "$DRYRUN" ]
then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment