Skip to content

Commit b4d925c

Browse files
authored
check POSIX mode more thoroughly (#724)
1 parent 1a86527 commit b4d925c

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

.github/workflows/ci.shellcode.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
- name: prep
4242
run: |
43-
apt-get update && apt-get --yes install unzip bash libatomic1
43+
apt-get update && apt-get --yes install bash libatomic1
4444
chmod u+x /usr/local/bin/tea
4545
4646
- run: |
@@ -107,6 +107,13 @@ jobs:
107107
eval "$(tea --shellcode)"
108108
test $(foo) = hi
109109
110+
- name: POSIXLY_CORRECT
111+
run: |
112+
eval "$(tea --shellcode)"
113+
tea +duf
114+
duf --version
115+
shell: bash -eo posix {0}
116+
110117
zsh:
111118
needs: compile
112119
runs-on: ubuntu-latest
@@ -122,7 +129,7 @@ jobs:
122129

123130
- name: prep
124131
run: |
125-
apt-get update && apt-get --yes install unzip zsh libatomic1
132+
apt-get update && apt-get --yes install zsh libatomic1
126133
chmod u+x /usr/local/bin/tea
127134
shell: sh # ∵ cannot be zsh until zsh is installed
128135

@@ -205,6 +212,13 @@ jobs:
205212
eval "$(tea --shellcode)"
206213
test $(foo) = hi
207214
215+
- name: emulate -L sh
216+
run: |
217+
emulate -L sh
218+
eval "$(tea --shellcode)"
219+
tea +duf
220+
duf --version
221+
208222
POSIX:
209223
needs: compile
210224
runs-on: ubuntu-latest
@@ -217,7 +231,7 @@ jobs:
217231

218232
- name: prep
219233
run: |
220-
apt-get update && apt-get --yes install unzip libatomic1
234+
apt-get update && apt-get --yes install libatomic1
221235
chmod u+x /usr/local/bin/tea
222236
223237
# NOTE matrix does not work for the shell key :-/
@@ -247,6 +261,15 @@ jobs:
247261
exit 3
248262
fi
249263
264+
# verifies our assumption that we are running in “POSIX mode”
265+
- name: tea@latest fails
266+
run: |
267+
eval "$(tea --shellcode)"
268+
269+
if tea@latest --version; then
270+
exit 1
271+
fi
272+
250273
- name: test `dev` shellcode
251274
run: |
252275
eval "$(tea --shellcode)"

docs/run/anywhere/terminals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting Started
22

3-
Installing with `brew` is most straight forward:
3+
Installing with [`brew`] is most straight forward:
44

55
```sh
66
brew install teaxyz/pkgs/tea-cli
@@ -19,7 +19,7 @@ brew install teaxyz/pkgs/tea-cli
1919
 
2020

2121
{% hint style='info' %}
22-
Wanna read that script before you execute it? [github.com/teaxyz/setup/install.sh][installer]
22+
Wanna read that script before you execute it? [github.com/teaxyz/setup/installer.sh][installer]
2323
{% endhint %}
2424

2525
2. `tea` is a standalone binary, so (if you want) you can also download it directly:
@@ -49,4 +49,4 @@ brew install teaxyz/pkgs/tea-cli
4949

5050
[`brew`]: https://brew.sh
5151
[GitHub Releases]: https://github.com/teaxyz/cli/releases
52-
[installer]: https://github.com/teaxyz/setup/blob/main/install.sh
52+
[installer]: https://github.com/teaxyz/setup/blob/main/installer.sh

src/modes/shellcode.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default function() {
130130
fi
131131
}
132132
133-
if test -n "$ZSH_VERSION"; then
133+
if [ -n "$ZSH_VERSION" ] && [ $(emulate) = zsh ]; then
134134
eval 'typeset -ag chpwd_functions
135135
136136
if [[ -z "\${chpwd_functions[(r)_tea_hook]+1}" ]]; then
@@ -145,18 +145,19 @@ export default function() {
145145
reply=($words)
146146
}
147147
compctl -K _tea tea'
148-
elif test -n "$BASH_VERSION"; then
148+
elif [ -n "$BASH_VERSION" ] && [ "$POSIXLY_CORRECT" != y ] ; then
149149
eval 'cd() {
150150
builtin cd "$@" || return
151151
_tea_chpwd_hook
152152
}
153153
154154
_tea_chpwd_hook'
155155
else
156+
POSIXLY_CORRECT=y
156157
echo "tea: warning: unsupported shell" >&2
157158
fi
158159
159-
if test -n "$BASH_VERSION$ZSH_VERSION"; then
160+
if [ "$POSIXLY_CORRECT" != y ]; then
160161
eval 'tea@latest() {
161162
command tea tea@latest "$@"
162163
}'

0 commit comments

Comments
 (0)