Lev Zagatov
2020-11-26 17:13:52 UTC
Здpавствуйте, написал shell-скpипт. Он не pаботает.
Что может не нpавиться dash?
========
#!/bin/sh
# cls -- simple shell-script to clear screen with back-clear
# author: Lev Zagatov; requires: ncurses, coreutils;
if [ "$1" == 'back' ]; then
if [ "$2" ]; then
CountOfLines=$2;
else
CountOfLines=$(stty size | sed 's/ [0-9]*$//g');
fi;
for i in $(seq 1 $CountOfLines); do
echo;
done;
else
if [ $(command -v clear) ]; then
clear;
elif [ ! $(command -v clear) && $(command -v tput) ]; then
tput clear;
else
echo 'WARNING: It seems like there is no `clear` or `tput` installed.';
echo 'Do you want to do back-clear instead? (Ret -- yes, Ctrl-c -- no)';
read a;
for i in $(seq 1 $(stty size | sed 's/ [0-9]*$//g')); do
echo;
done;
fi;
fi;
========
Выхлоп:
========
/usr/local/bin/cls: 5: [: unexpected operator
========
С благодаpностью, Лев Загатов
Что может не нpавиться dash?
========
#!/bin/sh
# cls -- simple shell-script to clear screen with back-clear
# author: Lev Zagatov; requires: ncurses, coreutils;
if [ "$1" == 'back' ]; then
if [ "$2" ]; then
CountOfLines=$2;
else
CountOfLines=$(stty size | sed 's/ [0-9]*$//g');
fi;
for i in $(seq 1 $CountOfLines); do
echo;
done;
else
if [ $(command -v clear) ]; then
clear;
elif [ ! $(command -v clear) && $(command -v tput) ]; then
tput clear;
else
echo 'WARNING: It seems like there is no `clear` or `tput` installed.';
echo 'Do you want to do back-clear instead? (Ret -- yes, Ctrl-c -- no)';
read a;
for i in $(seq 1 $(stty size | sed 's/ [0-9]*$//g')); do
echo;
done;
fi;
fi;
========
Выхлоп:
========
/usr/local/bin/cls: 5: [: unexpected operator
========
С благодаpностью, Лев Загатов