Skip to content

Commit 8117a40

Browse files
committed
Adding some missing informating to the readme
1 parent 1b81081 commit 8117a40

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Using Newline, you can make all of your source code neat and consistent before c
1515
* Can add a trailing newline to the end of files if one doesn't already exist, and remove excess trailing newlines from the end of files.
1616
* Supports any ASCII-like encoding of files such as UTF-8, UTF-8 without BOM or ISO-8859-1.
1717
* Supports Linux, OS X and Windows (with proper Unicode filename support).
18-
* Fast. Newline is written in C, and can process a 1GiB text file with 21 million lines in XXX on a regular HDD.
18+
* Fast. Newline is written in C, and can process a 1GiB text file with 21 million lines at a rate of 9.4 MiB/s on a regular HDD.
1919

2020
Newline doesn't perform any conversion of tab characters. If you want to convert tabs to spaces or vice-versa, please refer to the `expand` and `unexpand` programs respectively from the GNU Core Utilities.
2121

@@ -36,9 +36,11 @@ Each `FILE` argument specifies a text file to process. Options are applied to al
3636
Standard POSIX command line argument conventions apply, i.e. `newline -- --verbose -N` would process a file named `--verbose` and `-N`, `newline -NSv` is the same as `newline -N -S -v`, and `newline -tCRLF` is the same as `newline -t CRLF`.
3737

3838
### Recursively processing directory
39-
You can make use of a Bash or Batch script to run Newline on an entire directory. The following examples run Newline, and then convert tabs to spaces using `expand`.
39+
You can make use of a Bash or Batch script to run Newline on an entire directory.
4040

4141
#### Bash script
42+
This example also converts tabs to spaces using `expand`.
43+
4244
```bash
4345
#!/usr/bin/env bash
4446

@@ -48,13 +50,21 @@ directory="./My Project/src"
4850
# Specify the types of files to process
4951
files="*.py;*.md"
5052

51-
# Specify the command line for Newline
52-
newline="newline -vt LF"
53+
# Specify what to do with each file
54+
process_file() {
55+
temp_file="$(mktemp expand_XXXXXX.tmp)"
56+
expand --tabs=4 "$1" > "$temp_file"
57+
mv "$temp_file" "$1"
58+
newline -vt LF "$1"
59+
}
60+
61+
export -f process_file
5362

5463
echo $files | {
5564
IFS=";" read -r -a file_types
5665
for file_type in "${file_types[@]}"; do
57-
find "$directory" -iname "$file_type" -exec $newline {} \;
66+
find "$directory" -iname "$file_type" \
67+
-exec bash -c 'process_file "$0"' {} \;
5868
done
5969
}
6070
```
@@ -73,7 +83,7 @@ set newline=.\newline.exe -vt CRLF
7383
7484
for /r "%directory%" %%f in (%files%) do (
7585
%newline% "%%f"
76-
86+
7787
)
7888
```
7989
## Installation
@@ -98,4 +108,4 @@ The makefile doesn't require anything like Cygwin or MSYS to be installed as it
98108
This will install Newline to your Desktop.
99109

100110
## License
101-
Newline is licensed under the terms of the MIT license. See the `LICENSE` file for more information.
111+
Newline is licensed under the terms of the MIT license. See the `LICENSE` file for more information.

0 commit comments

Comments
 (0)