Skip to content

Commit 6d1c25b

Browse files
authored
Merge pull request #3 from kstr0k/posix-sh
convert to posix sh
2 parents 59ac601 + cd0756b commit 6d1c25b

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

test/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# From http://tldp.org/LDP/abs/html/debugging.html
33
VIMS=./vims
44

vims

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# The argument fixes were supplied by John Kugelman
33
# https://stackoverflow.com/a/44745698/2689923
4-
vim_cmds=()
54

65
PRINT_ALL=1
76
DISABLE_VIMRC=0
87
MODE=none
98

10-
while (($# > 0)); do
9+
set -- "$@" '---vims-end---'
10+
while :; do
1111
case "$1" in
12+
---vims-end---) shift; break;;
1213
-n|--silent|--quiet) PRINT_ALL=0;;
1314
-d|--disable-vimrc) DISABLE_VIMRC=1;;
1415
-e|--exe-mode) MODE=exe;;
@@ -18,11 +19,11 @@ while (($# > 0)); do
1819
-t|--turn-off-mode) MODE=none;;
1920
*)
2021
case "$MODE" in
21-
none) vim_cmds+=(-c "$1");;
22-
simple) vim_cmds+=(-c ":exe \"norm gg""$1""\"");;
23-
line-exe) vim_cmds+=(-c ":%g/.*/exe \"norm ""$1""\"");;
24-
exe) vim_cmds+=(-c "%g/$1/exe \"norm $2\""); shift;;
25-
inverse-exe) vim_cmds+=(-c "%v/$1/exe \"norm $2\""); shift;;
22+
none) set -- "$@" -c "$1" ;;
23+
simple) set -- "$@" -c ":exe \"norm gg""$1""\"";;
24+
line-exe) set -- "$@" -c ":%g/.*/exe \"norm ""$1""\"";;
25+
exe) set -- "$@" -c "%g/$1/exe \"norm $2\""; shift;;
26+
inverse-exe) set -- "$@" -c "%v/$1/exe \"norm $2\""; shift;;
2627
esac
2728
;;
2829
esac
@@ -33,10 +34,10 @@ done
3334
# Taken from Csaba Hoch:
3435
# https://groups.google.com/forum/#!msg/vim_use/NfqbCdUkDb4/Ir0faiNaFZwJ
3536
if [ "$PRINT_ALL" -eq "1" ]; then
36-
vim_cmds+=(-c ":%p")
37+
set -- "$@" -c ":%p"
3738
fi
3839
if [ "$DISABLE_VIMRC" -eq "1" ]; then
39-
vim_cmds=(-u NONE "${vim_cmds[@]}")
40+
set -- -u NONE "$@"
4041
fi
4142

42-
vim - -nes "${vim_cmds[@]}" -c ':q!' | tail -n +2
43+
vim - -nes "$@" -c ':q!' | tail -n +2

0 commit comments

Comments
 (0)