-
-
Save rszamszur/81ebc2e9cd55b49c613906a2243d01ac to your computer and use it in GitHub Desktop.
Bring your own shell together with your script. Stop giving a damn about {zsh, ksh, csh, ash, dash, fish} compatibility and focus on the actual work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh - | |
if [ "$1" != "--wrapped" ]; then | |
echo "[uw] start" | |
WD="$(mktemp -d)" | |
echo "[uw] download deps" | |
curl -L -s https://github.com/robxu9/bash-static/releases/download/5.1.016-1.2.2/bash-linux-x86_64 \ | |
-o "${WD}/bsh" && chmod +x "${WD}/bsh" | |
curl -L -s http://landley.net/toybox/downloads/binaries/0.8.6/toybox-x86_64 \ | |
-o "${WD}/toybox" && chmod +x "${WD}/toybox" | |
for i in $( | |
"${WD}/toybox"\ | |
| "${WD}/toybox" sed 's| |\n|g' | |
); do | |
"${WD}/toybox" ln -s "${WD}/toybox" "${WD}/${i}"; | |
done | |
echo "[uw] switching shells" | |
PATH="${WD}" bsh -- "$0" --wrapped "$@" | |
echo "[uw] cleanup" | |
rm -rf "${WD}" | |
echo "[uw] exit" | |
exit | |
fi | |
echo "[w] start" | |
shift | |
echo "[w] work" | |
env | grep ^PATH | |
which sed | |
printf '%q ' "$@" | |
echo | |
echo "[w] exit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment