~ubuntu-branches/ubuntu/trusty/abs-guide/trusty-proposed

« back to all changes in this revision

Viewing changes to paragraph-space.sh

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2014-01-01 12:26:22 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20140101122622-n04ky7hk3mt1x13l
Tags: 6.6-1
* New upstream release; thanks to Sébastien Villemot for the report;
  Closes: #733155
* debian/control
  - bump Standards-Version to 3.9.5 (no changes needed)
  - use packaging repository canonical URLs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
# paragraph-space.sh
3
 
# Ver. 2.0, Reldate 05Aug08
 
3
# Ver. 2.1, Reldate 29Jul12 [fixup]
4
4
 
5
5
# Inserts a blank line between paragraphs of a single-spaced text file.
6
6
# Usage: $0 <FILENAME
7
7
 
8
 
MINLEN=60        # May need to change this value.
 
8
MINLEN=60        # Change this value? It's a judgment call.
9
9
#  Assume lines shorter than $MINLEN characters ending in a period
10
 
#+ terminate a paragraph. See exercises at end of script.
 
10
#+ terminate a paragraph. See exercises below.
11
11
 
12
 
while read line  # For as many lines as the input file has...
 
12
while read line  # For as many lines as the input file has ...
13
13
do
14
14
  echo "$line"   # Output the line itself.
15
15
 
16
16
  len=${#line}
17
 
  if [[ "$len" -lt "$MINLEN" && "$line" =~ \[*\.\] ]]
 
17
  if [[ "$len" -lt "$MINLEN" && "$line" =~ [*{\.}]$ ]]
 
18
# if [[ "$len" -lt "$MINLEN" && "$line" =~ \[*\.\] ]]
 
19
# An update to Bash broke the previous version of this script. Ouch!
 
20
# Thank you, Halim Srama, for pointing this out and suggesting a fix.
18
21
    then echo    #  Add a blank line immediately
19
 
  fi             #+ after short line terminated by a period.
 
22
  fi             #+ after a short line terminated by a period.
20
23
done
21
24
 
22
25
exit