1
0
forked from aniani/vim

patch 9.1.0838: vimtutor is bash-specific

Problem:  vimtutor is bash-specific (after 17c71daf83f45c3ee8)
Solution: port back to POSIX sh (Aliaksei Budavei).

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Aliaksei Budavei 2024-11-04 19:43:22 +01:00 committed by Christian Brabandt
parent ac2bb9dfea
commit 09cc8c92d1
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 80 additions and 69 deletions

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
838,
/**/ /**/
837, 837,
/**/ /**/

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# Start Vim on a copy of the tutor file. # Start Vim on a copy of the tutor file.
@ -11,8 +11,7 @@
# Vim could be called "vim" or "vi". Also check for "vimN", for people who # Vim could be called "vim" or "vi". Also check for "vimN", for people who
# have Vim installed with its version number. # have Vim installed with its version number.
# We anticipate up to a future Vim 8.1 version :-). seq="vim vim91 vim90 vim81 vim80 vim8 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi"
seq="vim vim81 vim80 vim8 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi"
usage() usage()
{ {
@ -31,94 +30,104 @@ usage()
listOptions() listOptions()
{ {
declare -A language echo "==OPTIONS======================================================================================="
language[bar]=Bavarian echo "Chapter: 1"
language[bg]=Bulgarian printf "\tLang: %-3s => %s\n" \
language[ca]=Catalan bar Bavarian \
language[cs]=Czech bg Bulgarian \
language[da]=Danish ca Catalan \
language[de]=German cs Czech \
language[el]=Greek da Danish \
language[en]=English\(default\) de German \
language[eo]=Esperanto el Greek \
language[es]=Spanish en English\(default\) \
language[fr]=French eo Esperanto \
language[hr]=Croatian es Spanish \
language[hu]=Hungarian fr French \
language[it]=Italian hr Croatian \
language[ja]=Japanese hu Hungarian \
language[ko]=Korean it Italian \
language[lv]=Latvian ja Japanese \
language[nb]=Bokmål ko Korean \
language[nl]=Dutch lv Latvian \
language[no]=Norwegian nb Bokmål \
language[pl]=Polish nl Dutch \
language[pt]=Portuguese no Norwegian \
language[ru]=Russian pl Polish \
language[sk]=Slovak pt Portuguese \
language[sr]=Serbian ru Russian \
language[sv]=Swedish sk Slovak \
language[tr]=Turkish sr Serbian \
language[uk]=English sv Swedish \
language[vi]=Vietnamese tr Turkish \
language[zh]=Chinese uk English \
vi Vietnamese \
zh Chinese
echo "==OPTIONS=======================================================================================" echo "Chapter: 2"
echo "Chapter: 1" printf "\tLang: %-3s => %s\n" \
for code in bar bg ca cs da de el en eo es fr hr hu it ja ko lv nb nl no pl pt ru sk sr sv tr uk vi zh en English\(default\)
do echo "================================================================================================"
printf "\tLang: %s => %s\n" ${code} ${language[${code}]}
done
echo "Chapter: 2"
for code in en
do
printf "\tLang: %s => %s\n" ${code} ${language[${code}]}
done
echo "================================================================================================"
} }
validateLang() validateLang()
{ {
if [[ $xx =~ ^[^a-z]*$ ]]; then echo "Error: iso639 code must contain only [a-z]" && exit 1; fi case "$xx" in
if [ ${#xx} == 2 ] || [ ${#xx} == 3 ]; then :; else echo "Error: iso639 code must be 2 or 3 characters only" && exit 1; fi '' | *[!a-z]* )
echo "Error: iso639 code must contain only [a-z]"
exit 1
esac
case "${#xx}" in
[23] )
;;
* )
echo "Error: iso639 code must be 2 or 3 characters only"
exit 1
esac
export xx export xx
} }
validateChapter() validateChapter()
{ {
if [[ $cc =~ ^[0-9]*$ ]]; then :; else echo "Error: chapter argument must contain digits only" && exit 1; fi case "$cc" in
if [ $cc == "0" ]; then echo "Error: chapter must be non-zero" && exit 1; fi '' | *[!0-9]* )
if [ $cc == "00" ]; then echo "Error: chapter must be non-zero" && exit 1; fi echo "Error: chapter argument must contain digits only"
exit 1
;;
0 | 00 )
echo "Error: chapter must be non-zero"
exit 1
esac
export CHAPTER="$cc" export CHAPTER="$cc"
} }
shopt -s extglob
while [ "$1" != "" ]; do while [ "$1" != "" ]; do
case $1 in case "$1" in
-g | --gui ) seq="gvim gvim91 gvim90 gvim81 gvim80 gvim8 gvim74 gvim73 gvim72 gvim71 gvim70 gvim7 gvim6 $seq" -g | --gui ) seq="gvim gvim91 gvim90 gvim81 gvim80 gvim8 gvim74 gvim73 gvim72 gvim71 gvim70 gvim7 gvim6 $seq"
;; ;;
-l | --language ) shift -l | --language ) shift
xx=$1 xx="$1"
validateLang validateLang
;; ;;
-l[a-z][a-z]?([a-z]) ) xx=${1#*l} -l[a-z][a-z][a-z] | -l[a-z][a-z] )
validateLang export xx="${1#*l}"
;; ;;
--language[a-z][a-z]?([a-z]) ) xx=${1#*e} --language[a-z][a-z][a-z] | --language[a-z][a-z] )
validateLang export xx="${1#*e}"
;; ;;
[a-z][a-z]?([a-z]) ) xx=$1 [a-z][a-z][a-z] | [a-z][a-z] ) export xx="$1"
validateLang
;; ;;
-c | --chapter ) shift -c | --chapter ) shift
cc=$1 cc="$1"
validateChapter validateChapter
;; ;;
-c[0-9]?([0-9]) ) cc=${1#*c} -c[1-9][0-9] | -c[1-9] ) export CHAPTER="${1#*c}"
validateChapter
;; ;;
--chapter[0-9]?([0-9]) ) cc=${1#*r} --chapter[1-9][0-9] | --chapter[1-9] )
validateChapter export CHAPTER="${1#*r}"
;; ;;
-h | --help ) usage -h | --help ) usage
exit exit
@ -129,8 +138,8 @@ while [ "$1" != "" ]; do
"" ) ;; "" ) ;;
* ) usage * ) usage
exit 1 exit 1
esac esac
shift shift
done done
@ -161,10 +170,10 @@ fi
export TUTORCOPY export TUTORCOPY
# remove the copy of the tutor on exit # remove the copy of the tutor on exit
trap "rm -rf $TODELETE" 0 1 2 3 9 11 13 15 trap "rm -rf $TODELETE" EXIT HUP INT QUIT SEGV PIPE TERM
for i in $seq; do for i in $seq; do
testvim=$(which $i 2>/dev/null) testvim=$(command -v "$i" 2>/dev/null)
if test -f "$testvim"; then if test -f "$testvim"; then
VIM=$i VIM=$i
break break