Skip to content

Commit 168158a

Browse files
committed
sh on raw ubuntu !propogates $SHELL or $USER (#164)
1 parent c6b9c1e commit 168158a

File tree

8 files changed

+45
-35
lines changed

8 files changed

+45
-35
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
push:
33
branches:
44
- main
5+
workflow_dispatch:
56

67
permissions:
78
contents: read

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* [`install.sh`](./install.sh) is delivered when you `curl tea.xyz`.
44
* This repository also provides the `tea` GitHub Action.
55

6-
# GitHub Action 0.18.1
6+
# GitHub Action 0.18.2
77

88
```yaml
99
- uses: teaxyz/setup@v0

action.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { prefab, hooks, Path, utils, semver, SemVer } = require("@teaxyz/lib")
2-
const { install, link, resolve, hydrate } = prefab
1+
const { plumbing, hooks, Path, utils, semver, SemVer } = require("@teaxyz/lib")
32
const { getExecOutput, exec } = require("@actions/exec")
3+
const { install, link, resolve, hydrate } = plumbing
44
const { useConfig, useSync, useCellar } = hooks
55
const core = require('@actions/core')
66
const path = require('path')

dist/out/index.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ prepare() {
4848
#FIXME doesn’t seem to work through `gum` prompts
4949
trap "echo; exit" INT
5050

51-
if ! command -v tar >/dev/null 2>&1; then
51+
if ! command -v tar >/dev/null; then
5252
echo "tea: error: sorry. pls install tar :(" >&2
5353
fi
5454

@@ -94,12 +94,12 @@ prepare() {
9494
fi
9595

9696
if test $ZZ = 'gz'; then
97-
if command -v base64 >/dev/null 2>&1; then
97+
if command -v base64 >/dev/null; then
9898
BASE64_TARXZ="/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4AX/AFNdADMb7AG6cMNAaNMVK8FvZMaza8QKKTQY6wZ3kG/F814lHE9ruhkFO5DAG7XNamN7JMHavgmbbLacr72NaAzgGUXOstqUaGb6kbp7jrkF+3aQT12CAAB8Uikc1gG8RwABb4AMAAAAeGbHwbHEZ/sCAAAAAARZWg=="
9999
if echo "$BASE64_TARXZ" | base64 -d | tar Jtf - >/dev/null 2>&1; then
100100
ZZ=xz
101101
fi
102-
elif command -v uudecode >/dev/null 2>&1; then
102+
elif command -v uudecode >/dev/null; then
103103
TMPFILE=$(mktemp)
104104
cat >"$TMPFILE" <<-EOF
105105
begin 644 foo.tar.xz
@@ -125,7 +125,7 @@ prepare() {
125125

126126
if test -z "$TEA_DESTDIR"; then
127127
# update existing installation if found
128-
if command -v tea >/dev/null 2>&1; then
128+
if command -v tea >/dev/null; then
129129
set +e
130130
TEA_DESTDIR="$(tea --prefix --silent)"
131131
if test $? -eq 0 -a -n "$TEA_DESTDIR"; then
@@ -158,7 +158,7 @@ prepare() {
158158
esac
159159

160160
if test -z "$CURL"; then
161-
if command -v curl >/dev/null 2>&1; then
161+
if command -v curl >/dev/null; then
162162
CURL="curl -Ssf"
163163
elif test -f "$TEA_DESTDIR/curl.se/v*/bin/curl"; then
164164
CURL="$TEA_DESTDIR/curl.se/v*/bin/curl -Ssf"
@@ -171,7 +171,7 @@ prepare() {
171171
}
172172

173173
get_gum() {
174-
if command -v gum >/dev/null 2>&1; then
174+
if command -v gum >/dev/null; then
175175
TEA_GUM=gum
176176
elif test -n "$ALREADY_INSTALLED"; then
177177
TEA_GUM="tea --silent +charm.sh/gum gum"
@@ -354,7 +354,7 @@ check_path() {
354354
then
355355
mkdir -p /usr/local/bin
356356
ln -sf "$TEA_EXENAME" /usr/local/bin/tea
357-
elif command -v sudo >/dev/null 2>&1
357+
elif command -v sudo >/dev/null
358358
then
359359
sudo --reset-timestamp
360360
sudo mkdir -p /usr/local/bin
@@ -367,7 +367,7 @@ check_path() {
367367
EoMD
368368
fi
369369

370-
if ! command -v tea >/dev/null 2>&1
370+
if ! command -v tea >/dev/null
371371
then
372372

373373
echo #spacer
@@ -395,11 +395,20 @@ check_shell_magic() {
395395

396396
# foo knows I cannot tell you why $SHELL may be unset
397397
if test -z "$SHELL"; then
398-
if command -v finger >/dev/null 2>&1; then
398+
if test -z "$USER"; then
399+
if ! command -v whoami >/dev/null; then
400+
SHELL=bash
401+
else
402+
USER="$(whoami)"
403+
fi
404+
fi
405+
if test -n "$SHELL"; then
406+
: #noop: set above
407+
elif command -v finger >/dev/null; then
399408
SHELL="$(finger "$USER" | grep Shell | cut -d: -f3 | tr -d ' ')"
400-
elif command -v getent >/dev/null 2>&1; then
409+
elif command -v getent >/dev/null; then
401410
SHELL="$(getent passwd "$USER")"
402-
elif command -v id >/dev/null 2>&1; then
411+
elif command -v id >/dev/null; then
403412
SHELL="$(id -P | cut -d ':' -f 10)"
404413
# Try to fall back with some level of normalcy
405414
elif test "$(uname)" == "Darwin"; then
@@ -409,7 +418,7 @@ check_shell_magic() {
409418
fi
410419
fi
411420

412-
SHELL=$(basename "$SHELL") # just in case
421+
SHELL=$(basename "$SHELL")
413422

414423
__TEA_ONE_LINER="test -d \"$TEA_DESTDIR_WRITABLE\" && source <(\"$TEA_DESTDIR_WRITABLE/tea.xyz/v*/bin/tea\" --magic=$SHELL --silent)"
415424

@@ -502,7 +511,7 @@ fi
502511

503512
if ! test -d "$TEA_DESTDIR/tea.xyz/var/pantry"; then
504513
title="prefetching"
505-
elif command -v git >/dev/null 2>&1; then
514+
elif command -v git >/dev/null; then
506515
title="syncing"
507516
fi
508517

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"dependencies": {
33
"@actions/core": "^1.10.0",
44
"@actions/exec": "^1.1.1",
5-
"@teaxyz/lib": "^0.1.8"
5+
"@teaxyz/lib": "^0.4.2"
66
},
77
"devDependencies": {
88
"@vercel/ncc": "^0.36.1"

scripts/dist.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
set -e
44

5-
source <(tea --magic=bash)
5+
# source <(tea --magic=bash)
66

7-
npm i
7+
tea npm install --include=dev
88

99
rm -rf dist
1010

11-
npx -- ncc build action.js --minify --out dist/out
11+
tea npx -- ncc build action.js --minify --out dist/out
1212

1313
cp -R node_modules/koffi/build dist
1414

0 commit comments

Comments
 (0)