diff options
Diffstat (limited to 'fold.sh')
-rw-r--r-- | fold.sh | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/fold.sh b/fold.sh deleted file mode 100644 index ee88c6e..0000000 --- a/fold.sh +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | fold() { | ||
4 | shopt -s checkwinsize | ||
5 | ( | ||
6 | : | ||
7 | : | ||
8 | ) | ||
9 | width="${1:-$COLUMNS}" | ||
10 | while read -r line; do | ||
11 | : "${line// / }" | ||
12 | IFS=$'\n' read -d "" -ra words <<<"${line// /$'\n'}" | ||
13 | ll=0 | ||
14 | for word in "${words[@]}"; do | ||
15 | wl="${#word}" | ||
16 | if ((ll + wl > width)); then | ||
17 | printf '\n' | ||
18 | else | ||
19 | ((ll += wl)) | ||
20 | printf '%s ' "$word" | ||
21 | fi | ||
22 | done | ||
23 | done | ||
24 | } | ||
25 | |||
26 | fold "$@" | ||