mirror of
https://github.com/zdharma-continuum/zinit.git
synced 2026-09-10 07:36:38 -04:00
style: format single-line.zsh to zinit convention (#325)
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
parent
99a41e36a6
commit
c3529c8270
|
|
@ -1,19 +1,27 @@
|
|||
#!/usr/bin/env zsh
|
||||
#
|
||||
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors
|
||||
# Copyright (c) 2021-2022 zdharma-continuum and contributors
|
||||
|
||||
emulate -R zsh
|
||||
setopt extendedglob warncreateglobal typesetsilent rcquotes noshortloops
|
||||
setopt extendedglob noshortloops rcquotes typesetsilent warncreateglobal
|
||||
|
||||
local IFS= n=$'\n' r=$'\r' zero=$'\0'
|
||||
|
||||
{
|
||||
command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' \
|
||||
|| gstdbuf -o0 gtr '\r\n' '\n\0' \
|
||||
|| stdbuf -o0 tr '\r\n' '\n\0';
|
||||
print
|
||||
} 2>/dev/null | while read -r line;
|
||||
do
|
||||
if [[ $line == *$zero* ]]; then
|
||||
# cURL doesn't add a newline to progress bars
|
||||
# print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${line##*${zero}}"
|
||||
print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${line%${zero}}"
|
||||
else
|
||||
print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${${line//[${r}${n}]/}%\%*}${${(M)line%\%}:+%}"
|
||||
fi
|
||||
done
|
||||
|
||||
local zero=$'\0' r=$'\r' n=$'\n' IFS=
|
||||
{ command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' || \
|
||||
gstdbuf -o0 gtr '\r\n' '\n\0' || \
|
||||
stdbuf -o0 tr '\r\n' '\n\0'; print } 2>/dev/null | \
|
||||
while read -r line; do
|
||||
if [[ $line == *$zero* ]]; then
|
||||
# Unused by cURL (there's no newline after the previous progress bar)
|
||||
#print -nr -- $r${(l:COLUMNS:: :):-}$r${line##*$zero}
|
||||
print -nr -- $r${(l:COLUMNS:: :):-}$r${line%$zero}
|
||||
else
|
||||
print -nr -- $r${(l:COLUMNS:: :):-}$r${${line//[$r$n]/}%\%*}${${(M)line%\%}:+%}
|
||||
fi
|
||||
done
|
||||
print
|
||||
|
|
|
|||
Loading…
Reference in a new issue