Commit 1a27e63a authored by User expired's avatar User expired
Browse files

Print usage to standard error in all scripts

Otherwise it is easily lost in pipes so users
would miss any information on syntax errors.
parent 27eaa72b
Pipeline #25937 passed with stage
in 1 minute and 23 seconds
......@@ -2,11 +2,13 @@
# Convert most characters to ascii
function usage() {
echo "$(basename $0): Convert most characters to ascii"
echo ""
echo "USAGE: echo text | $(basename $0) [options]"
echo "Options (position sensitive):"
echo " -h print this help"
cat 1>&2 <<EOF
$(basename $0): Convert most characters to ascii
USAGE: echo text | $(basename $0) [options]
Options (position sensitive):
-h print this help
EOF
exit $1
}
......
......@@ -2,14 +2,16 @@
# Convert special characters from unicode to latex
function usage() {
echo "$(basename $0): Convert special characters from unicode to latex"
echo ""
echo "USAGE: echo text | $(basename $0) [-i file] [-f str] [options]"
echo "Options (position sensitive):"
echo " -h print this help"
echo " -s short replacement list for journal names"
echo " -i file edit file in place (do not read stdin)"
echo " -f str filter pattern for sed"
cat 1>&2 <<EOF
$(basename $0): Convert special characters from unicode to latex
USAGE: echo text | $(basename $0) [-i file] [-f str] [options]
Options (position sensitive):
-h print this help
-s short replacement list for journal names
-i file edit file in place (do not read stdin)
-f str filter pattern for sed
EOF
exit $1
}
......
......@@ -2,14 +2,16 @@
# Convert special characters from latex to unicode
function usage() {
echo "$(basename $0): Convert special characters from latex to unicode"
echo ""
echo "USAGE: echo text | $(basename $0) [-i file] [-f str] [options]"
echo "Options (position sensitive):"
echo " -h print this help"
echo " -s short replacement list for journal names"
echo " -i file edit file in place (do not read stdin)"
echo " -f str filter pattern for sed"
cat 1>&2 <<EOF
$(basename $0): Convert special characters from latex to unicode
USAGE: echo text | $(basename $0) [-i file] [-f str] [options]
Options (position sensitive):
-h print this help
-s short replacement list for journal names
-i file edit file in place (do not read stdin)
-f str filter pattern for sed
EOF
exit $1
}
......
......@@ -5,11 +5,13 @@
# preceding lines starting with an "@" sign.
function usage() {
echo "$(basename $0): Extract entries from bibfile by matching the citation key"
echo ""
echo "USAGE: $(basename $0) bibfile pattern [pattern]..."
echo "Options:"
echo " -h print this help"
cat 1>&2 <<EOF
$(basename $0): Extract entries from bibfile by matching the citation key
USAGE: $(basename $0) bibfile pattern [pattern]...
Options:
-h print this help
EOF
exit $1
}
if [ $# -lt 2 ]; then usage 1; fi
......
......@@ -2,14 +2,16 @@
# Format bibtex files in JabRef like style
function usage() {
echo "$(basename $0): Format bibtex files in JabRef like style"
echo ""
echo "USAGE: $(basename $0) bibfiles"
echo "Options:"
echo " -h print this help"
echo " -n show changes only"
echo " -u do not change field contents"
echo " -p print non ascii characters"
cat 1>&2 <<EOF
$(basename $0): Format bibtex files in JabRef like style
USAGE: $(basename $0) bibfiles
Options:
-h print this help
-n show changes only
-u do not change field contents
-p print non ascii characters
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -4,17 +4,19 @@
FMTSTR='$authors, $journal, $volume$number$pages ($year)'
 
function usage() {
echo "$(basename $0): Abbreviate journal names in bibtex files"
echo ""
echo "USAGE: $(basename $0) [-f str] bibfiles"
echo "Options:"
echo " -h print this help"
echo " -n show changes only"
echo " -f use full name (undo abbreviation)"
echo " -j provide journal title instead of 'bibfiles'"
echo " -k print list of known journal names"
echo " -p print list of journal names in bibfiles"
echo " -u print unknown journal names in bibfiles"
cat 1>&2 <<EOF
$(basename $0): Abbreviate journal names in bibtex files
USAGE: $(basename $0) [-f str] bibfiles
Options:
-h print this help
-n show changes only
-f use full name (undo abbreviation)
-j provide journal title instead of 'bibfiles'
-k print list of known journal names
-p print list of journal names in bibfiles
-u print unknown journal names in bibfiles
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -7,27 +7,29 @@
ALLOWED_CHARS="A-Za-z:0-9-"
function usage() {
echo "$(basename $0): Insert citekeys FirstAuthorYear:journal into bibtex file"
echo ""
echo "The automatically created citation key can be overridden by a"
echo "Citationkey field that is manually added to the bibtex entry."
echo " Options -u and -d have the same output format 'count<tab>key'."
echo "Call '$(basename $0) -u | cut -f2' for the list of (unique) keys"
echo "without counts (-d for duplicate keys)."
echo " Journal names are abbreviated before creating the citation key."
echo "To gain speed rather than stability, the option -s can be used."
echo ""
echo "USAGE: $(basename $0) bibfiles[:letter]"
echo "Optional letter suffix for year."
echo "Options:"
echo " -h print this help"
echo " -n show changes only"
echo " -i ignore case when updating keys"
echo " -p print actual keys"
echo " -d print duplicate keys"
echo " -u print unique keys"
echo " -q do not print new key"
echo " -s skip journal abbreviation"
cat 1>&2 <<EOF
$(basename $0): Insert citekeys FirstAuthorYear:journal into bibtex file
The automatically created citation key can be overridden by a
Citationkey field that is manually added to the bibtex entry.
Options -u and -d have the same output format 'count<tab>key'.
Call '$(basename $0) -u | cut -f2' for the list of (unique) keys
without counts (-d for duplicate keys).
Journal names are abbreviated before creating the citation key.
To gain speed rather than stability, the option -s can be used.
USAGE: $(basename $0) bibfiles[:letter]
Optional letter suffix for year.
Options:
-h print this help
-n show changes only
-i ignore case when updating keys
-p print actual keys
-d print duplicate keys
-u print unique keys
-q do not print new key
-s skip journal abbreviation
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -2,17 +2,19 @@
# Merge bibfiles into one targete file
function usage() {
echo "$(basename $0): Merge bibfiles into one target file"
echo ""
echo "Entries with keys already in target file are skipped."
echo "All files except the target file are checked for some"
echo "formatting requirements and preprocessed if desired."
echo ""
echo "USAGE: $(basename $0) targetfile bibfiles"
echo "Options:"
echo " -h print this help"
echo " -q quick run (do not check journal abbreviations)"
echo " -y always yes (apply all changes and merge)"
cat 1>&2 <<EOF
$(basename $0): Merge bibfiles into one target file
Entries with keys already in target file are skipped.
All files except the target file are checked for some
formatting requirements and preprocessed if desired.
USAGE: $(basename $0) targetfile bibfiles
Options:
-h print this help
-q quick run (do not check journal abbreviations)
-y always yes (apply all changes and merge)
EOF
exit $1
}
if [ $# -lt 2 ]; then usage 1; fi
......
......@@ -7,17 +7,19 @@
ALLOWED_CHARS="_A-Za-z:0-9-"
function usage() {
echo "$(basename $0): Print rename commands for bibtex files"
echo ""
echo "Journal names are abbreviated before creating the file name."
echo "To gain speed rather than stability, the option -s can be used."
echo ""
echo "USAGE: $(basename $0) bibfiles[:letter]"
echo "Optional letter suffix for year."
echo "Options:"
echo " -n show changes only"
echo " -h print this help"
echo " -s skip journal abbreviation"
cat 1>&2 <<EOF
$(basename $0): Print rename commands for bibtex files
Journal names are abbreviated before creating the file name.
To gain speed rather than stability, the option -s can be used.
USAGE: $(basename $0) bibfiles[:letter]
Optional letter suffix for year.
Options:
-n show changes only
-h print this help
-s skip journal abbreviation
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -2,16 +2,18 @@
# Sort bibfiles by citation keys
function usage() {
echo "$(basename $0): Sort bibfiles by citation keys"
echo ""
echo "Exact duplicates of an entry are silently dropped."
echo ""
echo "USAGE: $(basename $0) bibfiles"
echo "Options:"
echo " -h print this help"
echo " -c check for sorted input only"
echo " -i edit bibtex files in place"
echo " -r newest entries first (by year)"
cat 1>&2 <<EOF
$(basename $0): Sort bibfiles by citation keys
Exact duplicates of an entry are silently dropped.
USAGE: $(basename $0) bibfiles
Options:
-h print this help
-c check for sorted input only
-i edit bibtex files in place
-r newest entries first (by year)
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -4,14 +4,16 @@
# Each filename should read Filename.pdf.bib for Filename.pdf.
function usage() {
echo "$(basename $0): Insert reference to pdf file (JabRef style) into bibtex file"
echo ""
echo "USAGE: $(basename $0) bibfiles"
echo "Options:"
echo " -h print this help"
echo " -n show changes only"
echo " -r remove reference"
echo " -p print actual references"
cat 1>&2 <<EOF
$(basename $0): Insert reference to pdf file (JabRef style) into bibtex file
USAGE: $(basename $0) bibfiles
Options:
-h print this help
-n show changes only
-r remove reference
-p print actual references
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -5,14 +5,16 @@
# preceding lines starting with an "@" sign.
function usage() {
echo "$(basename $0): Separate bibfile into single files"
echo ""
echo "USAGE: $(basename $0) bibfiles"
echo "File entries are used for output filenames."
echo "Options:"
echo " -h print this help"
echo " -k all filenames from citation keys"
echo " -f force override of output files"
cat 1>&2 <<EOF
$(basename $0): Separate bibfile into single files
USAGE: $(basename $0) bibfiles
File entries are used for output filenames.
Options:
-h print this help
-k all filenames from citation keys
-f force override of output files
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -4,24 +4,26 @@
FMTSTR='$authors, $journal $volume$number$pages ($year)\n$title\n$link\n'
function usage() {
echo "$(basename $0): Print citation read from bibtex file"
echo ""
echo "USAGE: $(basename $0) [-f str] bibfiles"
echo "Options:"
echo " -h print this help"
echo " -u unabbreviated forenames"
echo " -s author forenames first"
echo " -r print page ranges"
echo " -l long journal name"
echo " -a journal abbreviation"
echo " -o one line citation"
echo " -b brief one line citation"
echo " -f str use format string 'str'"
echo "Default format string:"
echo " '$FMTSTR'"
echo "Field names:"
echo " authors, fauthor (first author), title, journal,"
echo " volume, number, pages, year, doi, url, link, key"
cat 1>&2 <<EOF
$(basename $0): Print citation read from bibtex file
USAGE: $(basename $0) [-f str] bibfiles
Options:
-h print this help
-u unabbreviated forenames
-s author forenames first
-r print page ranges
-l long journal name
-a journal abbreviation
-o one line citation
-b brief one line citation
-f str use format string 'str'
Default format string:
'$FMTSTR'
Field names:
authors, fauthor (first author), title, journal,
volume, number, pages, year, doi, url, link, key
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -2,15 +2,17 @@
# Unite bibfiles with sorted keys
function usage() {
echo "$(basename $0): Unite bibfiles with sorted keys"
echo ""
echo "Exact duplicates of an entry are silently dropped."
echo ""
echo "USAGE: $(basename $0) [-e] [-r] bibfiles"
echo "Options:"
echo " -h print this help"
echo " -e do not sort fields in entries"
echo " -r newest entries first (by year)"
cat 1>&2 <<EOF
$(basename $0): Unite bibfiles with sorted keys
Exact duplicates of an entry are silently dropped.
USAGE: $(basename $0) [-e] [-r] bibfiles
Options:
-h print this help
-e do not sort fields in entries
-r newest entries first (by year)
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -2,15 +2,17 @@
# Format and rename/move a pair of bib and pdf files
function usage() {
echo "$(basename $0): Format and rename/move bibtex files"
echo ""
echo "USAGE: $(basename $0) [target_dir] bibfiles"
echo "'target_dir' must be an existing directory."
echo "Options:"
echo " -h print this help"
echo " -n show changes only (basic formatting is applied)"
echo " -f full instead of abbreviated journal names"
echo " -u do not change field contents"
cat 1>&2 <<EOF
$(basename $0): Format and rename/move bibtex files
USAGE: $(basename $0) [target_dir] bibfiles
'target_dir' must be an existing directory.
Options:
-h print this help
-n show changes only (basic formatting is applied)
-f full instead of abbreviated journal names
-u do not change field contents
EOF
exit $1
}
if [ $# -lt 1 ]; then usage 1; fi
......
......@@ -2,18 +2,20 @@
# Format and rename/move a pair of bib and pdf files
function usage() {
echo "$(basename $0): Format and rename/move a pair of bib and pdf files"
echo ""
echo "USAGE: $(basename $0) [option] [target_dir] [pdffile] [bibfile]"
echo "If unspecified, files that are unique by suffix are chosen."
echo "The 'target_dir' must be an existing directory."
echo "Options:"
echo " -h print this help"
echo " -n show changes only"
echo " -f full instead of abbreviated journal names"
echo " -u do not change field contents"
echo " -l select newest files in directory"
echo " (.bibtex file is renamed to .bib)"
cat 1>&2 <<EOF
$(basename $0): Format and rename/move a pair of bib and pdf files
USAGE: $(basename $0) [option] [target_dir] [pdffile] [bibfile]
If unspecified, files that are unique by suffix are chosen.
The 'target_dir' must be an existing directory.
Options:
-h print this help
-n show changes only
-f full instead of abbreviated journal names
-u do not change field contents
-l select newest files in directory
(.bibtex file is renamed to .bib)
EOF
exit $1
}
# if [ $# -lt 1 ]; then usage 1; fi
......
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