diff options
Diffstat (limited to 'wrap')
-rwxr-xr-x | wrap | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/wrap b/wrap deleted file mode 100755 index 011aa58..0000000 --- a/wrap +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | wrap() { | ||
4 | local width="$1" | ||
5 | local len=0 | ||
6 | |||
7 | while read -r -a line; do | ||
8 | for word in "${line[@]}"; do | ||
9 | ((len += "${#word}" + 1)) | ||
10 | #printf '%s' "$len" | ||
11 | if ((len >= width)); then | ||
12 | printf '\n' | ||
13 | # ruler "$width" | ||
14 | len=${#word} | ||
15 | fi | ||
16 | printf '%s ' "$word" | ||
17 | done | ||
18 | done | ||
19 | printf '\n' | ||
20 | } | ||
21 | |||
22 | ruler() { | ||
23 | for ((i = 0; i < $1; i++)); do | ||
24 | printf '%s' "${2:--}" | ||
25 | done | ||
26 | printf '\n' | ||
27 | } | ||
28 | |||
29 | if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then | ||
30 | wrap "$@" | ||
31 | fi | ||