Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # pastebin https://pastebin.com/7r8C8S5S
- # docs:
- # https://unix.stackexchange.com/questions/111508/bash-test-if-word-is-in-set
- # https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
- echo
- echo -n "Potwierdzasz?(T/n): "
- read answ
- # commit=1
- # # zawieranie się znaków w zbiorze alternatywa dla łańcucha warunków w instrukcji 'if'
- # case $answ in
- # T|t) ;;
- # *) commit=0;;
- # esac
- #
- # echo "commit: $commit"
- # inny sposób:
- # if [[ "$answ" =~ ^(t|T)$ ]]; then
- # echo "Potwierdzenie"
- # else
- # echo "Rezygnacja"
- # fi
- # lub jeszcze inny sposób
- # https://unix.stackexchange.com/questions/111508/bash-test-if-word-is-in-set
- # read answ
- # for w in t T
- # do
- # if [ "$w" == "$answ" ]
- # then
- # yes=1
- # break
- # fi
- # done;
- # [ "$yes" == "1" ] && echo "$answ is in the list" ||
- # echo "$answ is not in the list"
- # użytkownik nacisnął [ENTER] czyli w domyśle potwierdza 'T' albo 't'
- if test -z "$answ"; then
- echo "Pusty znak w domyśle Potwierdzenie..."
- answ="T"
- fi
- # https://stackoverflow.com/questions/3826425/how-to-represent-multiple-conditions-in-a-shell-if-statement
- if [[ ("$answ" = "T" || "$answ" = "t") ]]; then
- # if test $answ = "T" || test $answ = "t"; then
- echo "Potwierdzenie"
- else
- echo "Rezygnacja"
- fi
- echo "Podano: $answ"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement