https://github.com/mortend/xbash
Friendly, portable wrapper around bash.
https://github.com/mortend/xbash
bash cross-platform npm-package shell-script
Last synced: 11 days ago
JSON representation
Friendly, portable wrapper around bash.
- Host: GitHub
- URL: https://github.com/mortend/xbash
- Owner: mortend
- License: mit
- Created: 2019-07-24T20:59:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-08T18:24:38.000Z (about 5 years ago)
- Last Synced: 2025-02-21T02:03:28.682Z (11 months ago)
- Topics: bash, cross-platform, npm-package, shell-script
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xbash
[](https://www.npmjs.com/package/xbash)
[](https://www.npmjs.com/package/xbash)
[](LICENSE)
> Friendly, portable wrapper around `bash`.
The wrapper is used to run shell-scripts in various [node-powered applications](https://github.com/fuse-open/uno). The wrapper makes sure that also `curl` and `unzip` are available inside `bash`, as needed by some [cross-platform installers](https://github.com/fuse-open/android-build-tools).
* On Windows, the wrapper finds your [Git for Windows] installation and will prefer to run commands from there.
* If a [Git for Windows] installation isn't found, and the commands aren't otherwise found, the wrapper will provide instructions on how to install [Git for Windows].
[Git for Windows]: https://git-scm.com/downloads
## Install
```
npm install xbash
```
This will install `bash` (alias `xbash`), a cross-platform wrapper around the real `bash` executable.
## Usage
This package gives you a reasonably portable way to use `bash` and other tools – in JavaScript or from command-line.
### JavaScript
```js
const bash = require('xbash');
bash(['-c', 'echo Hello World!'], process.exit);
```
### Command-Line
```
$ bash --version
ERROR: 'bash' was not found. This can be solved by installing Git.
Please get Git from https://git-scm.com/downloads and try again.
```
This happens when `bash` was not found. Running again after installing [Git for Windows].
```
$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
```
We can run scripts or invoke other commands (that aren't otherwise available in PATH).
```
$ bash script.bash
Hello World!
```
```
$ bash -c 'curl --version'
curl 7.65.1 (x86_64-w64-mingw32) libcurl/7.65.1 OpenSSL/1.1.1c (Schannel) zlib/1.2.11 libidn2/2.2.0 nghttp2/1.38.0
Release-Date: 2019-06-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz Metalink MultiSSL NTLM SPNEGO SSL SSPI TLS-SRP
```
```
$ bash -c 'unzip'
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
[...]
```
## Contributing
Please [report an issue](https://github.com/mortend/xbash/issues) if you encounter a problem, or [open a pull request](https://github.com/mortend/xbash/pulls) if you make a patch.