Open Electroid opened 6 months ago
I want to create a bun shell to use instead of bash, zsh, sh, etc. I started the simple project to think about how it is possible.
So, I have some questions:
For example:
$.register('add', (n1,n2) => {
return n1+n2;
})
$`add 2 5`
For example:
When I use the command $cd DIRNAME
, the work directory of the shell ($) changes to the new directory.
If these examples are possible, It will do a powerful to make a great shell alternative using Javascript.
It will be cool if Bun
will support cross platform unzip
for zip, 7z
etc, and cross platform wget
or similar which download a file (Windows
doesn't have wget
by default) and using fetch for download is slow.
cp
With the power of cp
, I can finally write some cross platform readable building scripts, to copy my manifest.json
to dist
. 😂
Why not implement the exec
command? Executing it to replace the current process is a crucial and convenient command.
Is it possible to add the wc
command ? It is not available on Windows.
unfortunately, curl not working with bun shell
import { $ } from 'bun';
async function main() {
const url = "https://jsonplaceholder.typicode.com/todos/1";
const curlCommand = `curl -X GET ${url}`;
try {
const result = await $`${curlCommand.trim()}`;
if (result.exitCode !== 0) {
console.error(`Curl command failed with exit code ${result.exitCode}`);
process.exit(1);
}
console.info(`Curl command succeeded with output:`);
console.info(result.stdout);
} catch (error) {
console.error(`Request failed: ${error.message}`);
process.exit(1);
}
}
main();
throws an error
bun: command not found: /usr/bin/curl -X GET https://jsonplaceholder.typicode.com/todos/1
sed
command would really be helpful too. find and replace is something I need often
It works well with running any of my scripts like
await $script.py ${args}
.quiet();
Therefore I'm sure there must be a simple way to make it work with all installed programs like "curl" in example above
This is a tracking issue for commands that we should implement as builtins in the Bun shell. Some of these are taken from GNU coreutils.
cat
touch
mkdir
cd
echo
pwd
which
rm
mv
ls
exit
true
false
cp
timeout
yes
basename
realpath
dirname
mktemp
truncate
head
tail
cut
uniq
seq
sleep
tee
date
sha1sum
sha224sum
sha256sum
sha384sum
sha512sum
md5sum
sort
printenv
env
whoami
who
uptime
This is not an exhaustive list, we can add commands as we think it's a good idea to implement.
While these will already be generally available on most posix systems, having them in the Shell will also allow them to be readily available on Windows when using Bun Shell.